17.5. Installation of Sphinx

17.5.1. Závislosti
17.5.2. Download and Compile
17.5.3. Vytvoření uživatele a skupiny
17.5.4. The Sphinx daemon
17.5.5. Configuration
17.5.6. Indexing documents

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

17.5.1. Závislosti

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

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

17.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*

17.5.3. Vytvoření uživatele a skupiny

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

17.5.4. The Sphinx daemon

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

17.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 database:

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

17.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 daemon:

# /etc/init.d/sphinx start

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

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