Install and configure Sphinx in Ubuntu

Sphinx – search engine with integration of API and MySQL databases, PostgreSQL.

Installation command:

sudo apt-get install sphinxsearch

After installation, tcp ports 9312 and 9306 are used.

Install the MySQL database server:

sudo apt-get install mysql-server mysql-client

Create a test database:

mysql -u root -p
CREATE DATABASE test;
SOURCE /etc/sphinxsearch/example.sql;
quit

Make a copy of the sample configuration file:

sudo cp /etc/sphinxsearch/sphinx.conf.sample /etc/sphinxsearch/sphinx.conf

Fill in the required parameters including data for connecting to the database.
An example of opening a configuration file in the nano editor (Ctrl+X to exit and y/n to save or discard changes):

sudo nano /etc/sphinxsearch/sphinx.conf

Activate sphinxsearch by specifying START=yes in the following file:

sudo nano /etc/default/sphinxsearch

Run sphinxsearch:

sudo service sphinxsearch start

Adding data to the index:

sudo indexer --all

An example of adding to cron:

sudo crontab -e
@hourly /usr/bin/indexer --rotate --config /etc/sphinxsearch/sphinx.conf --all

Command line search example:

search TEXT

Leave a comment

Leave a Reply