Want to add a search engine to your Web site but don't know how? Well, today's your lucky day! In this tutorial, find out how to obtain, install and use the popular ht://Dig indexing engine to add powerful, effective search capabilities to your site with minimal time and fuss.
First, you'll need to install ht://Dig on the Linux box you plan to use as a Web server. Drop by the official ht://Dig website and get yourself the latest stable release of the software (this tutorial uses ht://Dig 3.1.6). Note that you will need a C compiler and a running Web server in order to use the software (this tutorial uses GCC 3.2 and Apache 1.3.26).
Once you've downloaded the source code archive to your Linux server, log in as "root",
[output] $ su - Password: **** [/output]
and extract the source to a temporary directory.
$ cd /tmp $ tar -xzvf /home/me/htdig-3.1.6.tar.gz
The next step is to configure the package using the provided "configure" script. Before doing this, though, there are a couple of decisions you need to make.
There are two primary components to ht://Dig: the binaries used to index the site and create the database of search words, and the program used to perform a search on this database and return a result set. The indexing tools, and the database that results from their use, can be placed anywhere in the filesystem, but the search binary must be located in the Web server's CGI directory.
Additionally, the images used in the result page created after an ht://Dig search must also be located under the Web server root, so that they appear correctly when the page is viewed through a Web browser (assuming, of course, that you're using the default result page templates).
Given this information, and assuming the Web server is located in "/usr/local/apache/", the server's CGI area is "/usr/local/apache/cgi-bin/" and the server's document root is "/usr/local/apache/htdocs/", you will need to give the "configure" script the following arguments:
$ cd /tmp/htdig-3.1.6 $ ./configure --prefix=/usr/local/htdig --with-cgi-bin-dir=/usr/local/apache/cgi-bin/ --with-image-dir=/usr/local/apache/htdocs/htdig/images --with-image-url-prefix=/htdig/images --with-search-dir=/usr/local/apache/htdocs/htdig/sample
This tells the system to install the indexing tools to "/usr/local/htdig/", the CGI search binary to "/usr/local/apache/cgi-bin/", and the result page images and a sample search form to directories under "/usr/local/apache/htdocs/htdig/".