Sphinx search 3 installation with binary on Ubuntu for working with Thinking sphinx gem on ruby on rails
curl http://sphinxsearch.com/files/sphinx-3.3.1-b72d67b-linux-amd64.tar.gz -o sphinx.tar.gz
sudo tar -zxvf sphinx.tar.gz
sudo mv sphinx-3.3.1/bin/* /usr/local/bin/.
whereis searchd
This command will output following
searchd: /usr/local/bin/searchd
- First - create paths we need to store indexes, config files, logs and etc.
sudo mkdir -p /etc/sphinx /var/run/sphinx /var/log/sphinx /var/lib/sphinx/data
- Change permission for system user. Change deploy with your system user and group.
sudo chown -R deploy:deploy /etc/sphinx /var/run/sphinx /var/log/sphinx /var/lib/sphinx
chown user:group https://linuxize.com/post/linux-chown-command
- Creating Systemd service file:
Create this file /lib/systemd/system/sphinx.service and put following code
[Unit]
Description=Sphinx Search - Fast standalone full-text SQL search engine
After=network.target
[Service]
ExecStart=/usr/local/bin/searchd --config /etc/sphinx/sphinx.conf
ExecStop=/usr/local/bin/searchd --stop
KillMode=process
Restart=on-failure
PIDFile=/var/run/sphinx/sphinx.pid
User=sphinx
Group=sphinx
[Install]
WantedBy=multi-user.target
Alias=sphinx.service
- File, indicating our OS to restore /var/run/sphinx folder with write permissions for sphinx user:
Create this file - /usr/lib/tmpfiles.d/sphinx.conf and put following code
#Type Path Mode UID GID Age Argument
d /var/run/sphinx 0755 deploy deploy - -
- Enable systemd service Enter this to enable system service:
sudo systemctl enable sphinx
You'l get something like:
Created symlink /etc/systemd/system/sphinx.service → /lib/systemd/system/sphinx.service.
- Now go to rails project with thinking sphinx gem installed and run following commands.
bundle exec rake ts:clear
bundle exec rake ts:configure
bundle exec rake ts:start
bundle exec rake ts:index
Now sphinx should be running with thinking sphinx gem