Download and Install Sphinx

Sphinx can be downloaded from http://www.sphinxsearch.com/. Installing Sphinx is pretty straightforward. Following are the steps. --prefix defines the installation directory.

$ cd /home/me/src
$ wget http://sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz
$ tar -xzvf sphinx-0.9.8.tar.gz
$ cd sphinx-0.9.8
$ mkdir /usr/local/sphinx
$ ./configure --prefix /usr/local/sphinx --with-mysql
$ make
$ make install

Troubleshooting
If you get an error like:

sphinx.h:54:19: error: mysql.h: No such file or directory

It is because you do not have mysql-devel installed on your system. To fix this you need to install mysql-devel and mysql-libs, if you don't already have it installed.

If you are using Fedora, use:

$ yum install mysql-devel

If you are using Ubuntu:

$ apt-get install mysql-devel

Sample Database

The next step is to configure and test Sphinx. Here we create a sample database to walk through configuration and testing.

mysql> create table phonebook (
    -> id int(10) not null auto_increment primary key,
		-> name varchar(15) not null,
		-> phone varchar(20) not null
		-> );

mysql> describe phonebook;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(10)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(15) | NO   |     |         |                |
| phone | varchar(20) | NO   |     |         |                |
+-------+-------------+------+-----+---------+----------------+

mysql> insert into phonebook VALUES (NULL,'John','212-123-0987');
mysql> insert into phonebook VALUES (NULL,'Jake','718-123-0987');
mysql> insert into phonebook VALUES (NULL,'Kate','987-123-2322');
mysql> insert into phonebook VALUES (NULL,'Khan','987-893-2322');
mysql> insert into phonebook VALUES (NULL,'Mike','829-893-2322');

mysql> select * from phonebook;
+----+------+--------------+
| id | name | phone        |
+----+------+--------------+
|  1 | John | 212-123-0987 |
|  2 | Jake | 718-123-0987 |
|  3 | Kate | 987-123-2322 |
|  4 | Khan | 987-893-2322 |
|  5 | Mike | 829-893-2322 |
+----+------+--------------+

Note that Sphinx requires a unique integer indentifier (primary key) for each row