Sphinx is known as an open source full text search server, designed from the ground up with performance, relevance (aka search quality), and integration simplicity in mind.

Over the years, I had multiple requests from customers to implement sphinx on their  VPS or dedicated servers, with cPanel and MySQL 5.1 or 5.5, so I came up with the installation steps below.

These steps can be followed to install Sphinx on a cPanel server with MySQL 5.5.

Firstly, you need to identify the exact version of your MySQL server:

mysqladmin version

In our case, the output of this command results in version 5.5.32:

mysqladmin  Ver 8.42 Distrib 5.5.32, for Linux on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version        5.5.32-cll

Protocol version    10

Connection        Localhost via UNIX socket

UNIX socket        /var/lib/mysql/mysql.sock
Uptime:            2 min 50 sec

Threads: 1  Questions: 13  Slow queries: 0  Opens: 37  Flush tables: 1  Open tables: 30  Queries per second avg: 0.076

After identifying the version, we need to download the MySQL package corresponding to this version and extract the arhive:

cd /usr/local/src/

wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.32.tar.gz

tar zxf mysql-5.5.32.tar.gz

Next, we will download and extract the latest stable sphinx release, in our case version 2.0.9:

wget http://sphinxsearch.com/files/sphinx-2.0.9-release.tar.gz

tar zxf sphinx-2.0.9-release.tar.gz

Next, we will have to copy sphinx files into the downloaded MySQL package and configure and make (without installing!) this package in order to obtain the needed sphinx plugin files:

cp -Rf /usr/local/src/sphinx-2.0.9-release/mysqlse/ /usr/local/src/mysql-5.5.32/sphinx/

sh BUILD/autorun.sh

./configure

make

Important Note! DO NOT execute the install command, only the mentioned commands above.

After executing these commands, some plugin files will result after the make and we need to add them to our MySQL instance.

Firstly, let’s create the plugin folder and add it to our MySQL configuration:

mkdir /var/lib/mysql/plugins

And add in the /etc/my.cnf the line:

plugin_dir=”/var/lib/mysql/plugins”

Next, let’s copy the plugin files into thier directory:

cp /usr/local/src/mysql-5.5.32/storage/sphinx/ha_sphinx.* /var/lib/mysql/plugins/

And restart MySQL:

service mysql restart

Enter MySQL command line:

mysql

And install the plugin by executing:

INSTALL PLUGIN sphinx SONAME ‘ha_sphinx.so’;

Now let’s check the available engines, we should identify sphinx there:

show engines;
+——————–+———+—————————————————————-+————–+——+————+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+——————–+———+—————————————————————-+————–+——+————+
| MyISAM             | DEFAULT | MyISAM storage engine                                          | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| SPHINX             | YES     | Sphinx storage engine 2.0.9-release                            | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| InnoDB             | YES     | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
+——————–+———+—————————————————————-+————–+——+————+
10 rows in set (0.00 sec)

 

Congratulations, you have successfully installed Sphinx on your cPanel server with MySQL 5.5!

[sdonations]1[/sdonations]

1 COMMENT

  1. Followed your guide step for step using mysql 5.5.32 and sphinx 2.2.7 all is fine however after make finishes I try to copy the files and:

    cp /usr/local/src/mysql-5.5.32/storage/sphinx/ha_sphinx.* /var/lib/mysql/plugins/
    cp: cannot stat `/usr/local/src/mysql-5.5.32/storage/sphinx/ha_sphinx.*’: No such file or directory

    There’s no sphinx folder in storage :(.

Leave a Reply