4

When my server (running CENTOS) is restarted I have to manually start searchd for each website I use Sphinx on.

It's not hard to do (just copy/paste one line in the terminal for each site), but if I forget to do it, or am not aware that the server has been restarted, then search will be down on my websites.

The command I'm referring to to start searchd is this:

/usr/local/bin/searchd --config /path/to/sphinx/etc/sphinx.conf

Is there a way to have searchd automatically start up when my server is restarted?

Nate
  • 1,723

4 Answers4

7

in my case (Debian 8.9)

  /usr/bin/searchd --config /etc/sphinxsearch/sphinx.conf 

does not start sphinx and instead I need to run

  sudo service sphinxsearch start

to get sphinx started

The answer from harrymc pointed me to the right solution and when I edited

  sudo nano /etc/rc.local

and included

  sudo service sphinxsearch start 

just before the exit 0 line, then it finally loaded sphinx upon reboot.

4

To configure Sphinx to start automatically, start by adding the searchd start command to the server rc.local file :

sudo vim /etc/rc.local

Paste the following code just above the exit 0 line :

/usr/bin/searchd --config /var/www/yoursitecom/sphinx/etc/sphinx.conf

Now that everything is setup and running, to make sure that the index stays up-to-date with the database, run a crontab to rotate (rebuild) the index every 6 hours :

sudo crontab -e

Add the following line to the bottom of the document.

0 */6 * * * /usr/bin/indexer --rotate --config /var/www/yoursitecom/sphinx/etc/sphinx.conf --all

Source : Working with Sphinx (Search Engine) on a LAMP (Linux, Apache, MySQL, and PHP) Stack Server.

harrymc
  • 498,455
0

You may also consider using something like supervisor. It is not as simple as using /etc/rc.local and it require some configuration but it gives more flexibility.

dtoubelis
  • 136
-1

In my case works this:

in /etc/rc.local

I added line: service searchd start

Mureinik
  • 4,152
Tomas
  • 1