5. Installation of Sphinx

Sphinx is the indexer for the database used by Locum and Insurge.

There is no Debian package for Sphinx so you'll have to compile the source directly:

# apt-get install g++ make libmysql++-dev
$ wget http://sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz
$ tar zxvf sphinx-0.9.8.tar.gz
$ cd sphinx-0.9.8
$ ./configure --prefix=/usr/local/sphinx
$ make
# make install
# mkdir /usr/local/sphinx
# mkdir /usr/local/sphinx/lib
# cp api/sphinxapi.php /usr/local/sphinx/lib/
$ rm -R sphinx-0.9.8*

Creating a Sphinx user and change the owner:

# adduser sphinx
# addgroup sphinx
# usermod -G sphinx sphinx
# mkdir /usr/local/sphinx/var/run
# chown -R sphinx.sphinx /usr/local/sphinx/var

Download:

# cd /etc/init.d
# wget http://www.thesocialopac.net/sites/thesocialopac.net/files/sphinx
# chmod +x /etc/init.d/sphinx

Add Sphinx to the default boot services:

# update-rc.d sphinx defaults

Copy the configuration file supplied with the source of Sphinx before the change:

# cp /usr/local/lib/locum/sphinx/sphinx.conf /usr/local/sphinx/etc/
# sed 's/locum_db_user/scas_user/g' /usr/local/sphinx/etc/sphinx.conf > tmpfile;
mv tmpfile /usr/local/sphinx/etc/sphinx.conf
# sed 's/locum_db_pass/scas_pass/g' /usr/local/sphinx/etc/sphinx.conf > tmpfile; mv tmpfile /usr/local/sphinx/etc/sphinx.conf

And if you personalize the name of the database:

# sed 's/scas/MY_DB/g' /usr/local/sphinx/etc/sphinx.conf > tmpfile; mv tmpfile /usr/local/sphinx/etc/sphinx.conf

Indexing is necessary if you want to use the search features of SOPAC.

You must first complete the Insurge table index

# chmod +x /usr/local/lib/insurge/tools/update-index.php
$ /usr/local/lib/insurge/tools/update-index.php

Then start indexing Sphinx

$ /usr/local/sphinx/bin/indexer --all

Finally, we must start the daemon:

# /etc/init.d/sphinx start

When the daemon is running, you can update the index with:

$ /usr/local/sphinx/bin/indexer --all --rotate