5. Installation of Sphinx

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

5.1. Dependencies

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

# apt-get install g++ make libmysql++-dev

5.2. Download and Compile

$ 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*

5.3. Creation of User and Group

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

5.4. The demon Sphinx


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

Add Sphinx in the service at boot:

# update-rc.d sphinx defaults

5.5. Configuration

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 BDD:

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

5.6. Indexing documents

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 demon:

# /etc/init.d/sphinx start

When the demon is already en route, you can update the index with:

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