KSearch - An Excellent Free Website Indexer and Search Engine Script
by Rich Deem

Introduction

Several companies offer free offsite search for your website. The best of these and the one I used for a couple years was Atomz (www.atomz.com). The disadvantage of using one of these services is that they add either advertisements or links off your site. Most do not offer custom templates so that your search results page does not match your site navigation (with Atomz being the exception). Atomz has the disadvantage of only offering its free services to sites with fewer than 500 pages. When this site went over 500 pages, I began to search for a free search script that didn't require ads. After testing many different free website search engines, I have determined that KSearch is the best free script. However, its relevance was not as good as Atomz or FM SiteSearch Pro (an inexpensive site search script).

Installation

This is a simplified, "quick and dirty" instruction set to get the program up and running.

  1. Download the program at http://www.kscripts.com/.
  2. Extract the downloaded program using Win Zip or other zip extraction program.
  3. Open the "ksearch" folder. Open the "ksearch.cgi" file with a text editor (like Notepad, BBedit, etc.). Edit the first line (Path to Perl) if necessary. For most hosts, no editing will be necessary (default is "#!/usr/bin/perl").
  4. Open the "configuration" folder within the "ksearch" folder. Open the "configuration.pl" file with a text editor. You must edit four settings within this file. If your hosting service uses CPANEL, these are the settings you should use:
    1. $INDEXER_START = '/home/yourusername/public_html/';
    2. $BASE_URL ='http://www.yourwebsite.com/';
    3. $SEARCH_URL = "http://yourwebsite.com/cgi-bin/ksearch/ksearch.cgi";
    4. $KSEARCH_DIR = '/home/yourusername/public_html/cgi-bin/ksearch/'; # re-index
  5. Other settings in the "configuration.pl" file may be edited, depending upon how you want the searches to be done. For most users, the default settings are fine.
  6. If there are directories that you do not want searched, you must edit the "ignore_files.txt" file within the "configuration" folder (e.g., /home/yourusername/public_html/cgi-bin).
  7. Upload the entire "ksearch" folder using an FTP client into the cgi-bin directory where your html files go. Change the permissions of the "ksearch.cgi", "indexer.pl", and "indexer.cgi" files within the "ksearch" folder to 755.
  8. There are two ways to index your site. One way is to run the "indexer.cgi" file from within your browser (in order to do this, you must enter a password where indicated in the "configuration.pl" file). This script may or may not work, depending upon how large your site is and how long a script is allowed to run on your host before timing out. The documentation indicates that the script will probably timeout on large websites and, thus, fail to index your site. I recommend using indexer.pl from Telnet. Here are the instructions for doing this if your host uses CPANEL:
    1. Log into your control panel. Click the link that is labeled "SSH Session" (it may be labeled "SSH/Telnet shell access" under the "Access Menu", depending upon which version of CPANEL is running). The browser will start another process that will appear in a separate window. Alternatively you can use a standalone program, such as PuTTY.
    2. When the prompt comes up, hit "Enter". Another prompt will prompt for your username (the same one you use for CPANEL). Type in your username and press "Enter". If you are prompted with an error message, click "yes" to continue.
    3. Enter your password and "Enter".
    4. Type "/home/yourusername/public_html/cgi-bin/ksearch/indexer.pl" and enter. The display will show the files as they are being processed. When the program has completed, it will indicate how many files were processed and the processing time. For this site, it took ~5 minutes for 1,477 files (16,173 KB) with 1,500,894 total search terms.
    5. Exit your Telnet session.
  9. You can do a simple search using the following code:
    <form action="http://yourwebsite.com/cgi-bin/ksearch/ksearch.cgi" method="get" name="search">
    <input type="text" name="terms"><input type="submit" value="Search">
    </form>
  10. A more advanced search form is available with the documentation ("search_form.html") or see below.

Templates

Templates are not necessary, but provide a way to match the look and navigation of your site. Create the template using your favorite HTML editor or use one that you have already created. The default Ksearch template ("search.html") is located within the "templates" folder within the "ksearch" folder. Make sure that you use absolute links (e.g., "/images/your.jpg") so that all your images, scripts, and stylesheets are referenced correctly. Copy the code from the "search.html" page into your template and upload the revised "search.html" file into your cgi-bin/ksearch/templates folder.

Conclusion Top of page

There are many more options and much more documentation on the KSearch website. However, these brief instructions will get you going without having to wade through their documentation. Check KSearch in action on this site:

    +

Case Sensitive
Whole Words Only
Include Stop-Terms
Sort by
Display

Search Content
Body Title Url Alt-Text Links Default
Meta-Description Meta-Keywords Meta-Authors

Daily Deals from Buy.com
We are a leading retailer focused on providing a positive shopping experience & competitive prices and free shipping for over 12 million products.

http://www.godandscience.org/general/ksearch.html
Last Modified December 10, 2007

 

Rich's Blog