Logan Bailey

Adventures In Web Development

Blog, About, GitHub, and LinkedIn

Sphinx is an open-source full-text search server, designed from the ground up with performance, relevance (aka search quality), and integration simplicity in mind. It supports multiple databases as well as files and streaming data. It has a command line implementation as well as API's in many different languages. This guide will go over installation, setup, as well as some common problems that many first time users have while working with the LAMP stack.


Installation can be anywhere on the system, it's not particularly important. Open the Sphinx Website and find the version that corresponds with your OS, I use CENTOS in this example:

wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
tar xzvf sphinx-0.9.8.tar.gz
cd sphinx-0.9.8
make install
cp sphinx.conf.dist sphinx.conf
mysql --user=USERNAME --password=PASSWORD < example.sql
sudo mkdir /var/data/test1
chmod 755 /var/data/test1

This will download, unzip, compile the binary, and install 3 binaries.

  • indexer - the tool which will build the "indexes" to search
  • search - a command line tool to run searches on
  • searchd - the search daemon that will be powering most searches

Setting Up the Config File

Open up the sphinx.conf file we just created in any text editor and correctly set the follow properties of source scr1

  • sql_host
  • sql_user
  • sql_pass

If you opted to save your indexes else where goto line 280 where you should find path = /var/data/test1 change the path to be where you want to store the indexes. Save the file and close it.

Your First Index

Now by default Sphinx installed indexer to /usr/local/bin/indexer, which should be setup in your include path if not use the absolute path. Feel free to run just indexer to see all of the command line arguments. Run indexer test1. This will create the indexes for the test data we created from the sql file. Now that you created your first index lets run our first search type search test. You'll see some search results about the example data we have created.

Posted In: