Installing htdig

Htdig works with the Web server apache to create a database of terms that people can use to search your website. Unfortunately, in the default installation on many Linux distributions htdig contains hard-coded paths indicating that the htdig files are to be found in weird locations. Trying to change the paths is not worth the effort--you will end up with unmaintainable links all over the place. The easiest solution is to install a new version and force all the paths to known, sensible values. This is done by specifying the paths in the configure script.


configure --prefix=/usr/local/httpd/htdig\
 --bindir=/usr/local/httpd/htdig \
 --with-conf-dir=/etc/htdig \
 --with-default-config-file=/etc/htdig/htdig.conf \
 --with-common-dir=/usr/local/httpd/htdig \
 --with-database-dir=/usr/local/httpd/htdig \
 --with-cgi-bin-dir=/usr/local/httpd/cgi-bin \
 --with-image-dir=/usr/local/httpd/htdig \
 --with-image-url-prefix=/htdig \
I specified that all of htdig's files, except for the config file, should go in one big directory. This makes them easy to find.

Next, make sure the paths were correctly copied into the makefiles:
cat */Makefile | grep opt/www   
This should not print anything unless you specified "opt/www" as the location for some of the files.
Then compile and install htdig:
make install
Write down the location where rundig actually got installed.

Remove any old rundig, htsearch, htdig, htmerge, and htnotify (for example, in /usr/bin or cgi-bin).

The compilation script still may ignore the specified parameters and build a copy of htdig that expects a configuration file to be in some weird location, such as the /usr/local/htdig/conf directory. Run `strings' against the binary to find out where htsearch thinks the config file is located:
cd htsearch
strings htsearch | grep conf
Go to the directory that it prints, move the htdig.conf file to a more reasonable place, such as /etc/htdig/htdig.conf, and replace the old htdig.conf with a link.
cd /usr/local/httpd/htdig/conf/
mv htdig.conf /etc/htdig/htdig.conf
ln -s /etc/htdig/htdig.conf htdig.conf


Edit /etc/htdig/htdig.conf and change the parameters to match your site.

As root, run `htdig -v' and make sure it is reading the correct files from your site. If you forget to edit the config file, or if you edit the wrong one, it will read files from the htdig homepage instead, which is not what you want.

As root, run `rundig' to create the database.
Put `rundig' in root's crontab.
Copy `search.html' to your main htdocs directory, edit it if desired, add <A HREF="search.html">Site Search</A> to some web page, and activate cgi in /etc/httpd/httpd.conf.

Next, it's necessary to move the images. Make a directory in your htdocs directory (where your index.html is located), called htdig. Then copy star.gif and htdig.gif in this new directory, and make a link to wherever button1.gif et al. are located.
cd htdocs/htdig
ln -s ../../htdig/images images
Quite frequently, people discover that htdig is able to find star.gif, but not the button images. This is because the default htdig.conf file contains an error. In /etc/htdig/htdig.conf change all occurrences of

Finally, customize your installation by substituting a custom image for htdig.gif. Otherwise, your site will have a big "htdig" advertisement on its search results page.