Adding Self-Hosted Search to My Site

I have recently been unhappy with DuckDuckGo’s indexing of my site. I considered changing back to a Google based search, but I figured there had to be something that let me have more control. I found my solution in a Macdrifter post about self-hosted search: Sphider. It is a php-based, self-hosted, search engine and it seems to work like a charm.

A couple of quick things that are not covered on Macdrifter:

  • There’s an error in the SQL script you have to run to setup the database. Remove the “(14)” from the timestamp line for the creation of the query_log table near the end of the script 1
  • If you want to edit the search box on a WordPress installation, you edit the “searchform.php” page in your theme directory2 My search form looks like this:

    <form action="http://search.johnkiv.us/search.php" method="get">
        <input type="text" value="To search type and hit enter" onfocus="if(this.value=='To search type and hit enter')this.value='';" onblur="if(this.value=='')this.value='To search type and hit enter';" name="query" id="query" />
        <input class="hidden" type="submit" id="searchsubmit" value="Search" />
        <input type="hidden" name="type" value="and" />
        <input type="hidden" name="results" value="50" />
        <input type="hidden" name="search" value="1" />
    </form>
    
  • If you do not edit the default template that comes with Sphider then people who get to your search results have no link back to the page they just came from3. This bothers me from a usability perspective, so I added a couple of “Return to Previous Page” buttons to the “search_results.html” page.

Overall, the setup process, including the time it took me to style my search results, took me closer to two and a half hours, instead of one hour mentioned in the Macdrifter post. That said, I am really happy with the results.


  1. If you choose to use the “install.php” file instead of the SQL script, you have to make the same removal. In my version, it is on line 139. 

  2. Or create that page if it does not exist. 

  3. Other than the back button of course.