Sphinx daemon in Ubuntu

Sphinx daemon in Ubuntu

Read the bottom of this post to see the updated version!

After install Sphinx Search following the instructions here, I wanted to get the daemon (searchd) running automatically after my Ubuntu Server box restarts.

The trick is to install the daemon in the init.d doing the following (as a root sudo -s):

First, create /etc/init.d/searchd with this content:

#!/bin/sh
case "${1:-''}" in
'start')
/usr/local/sphinx/bin/searchd
;;
'stop')
/usr/local/sphinx/bin/searchd --stop
;;
'status')
/usr/local/sphinx/bin/searchd --status
;;
'iostats')
/usr/local/sphinx/bin/searchd --iostats
;;
'cpustats')
/usr/local/sphinx/bin/searchd --cpustats
;;
*)
echo "Usage: $SELF start|stop|status|iostats|cpustats"
exit 1
;;
esac
exit 0

Change the mod with: chmod a+x /etc/init.d/searchd

Last, execute this command to add the script into the runlevels: update-rc.d searchd defaults

That’s it. :)

UPDATE: Since Sphinxsearch now has a .DEB file to download, you could have it installed from that source in 5′ :) Just go to http://sphinxsearch.com/downloads/release/ get the .DEB (32 or 64 bits) and run: dpkg –install XXXXX.deb (where XXXXX.deb should be the name of the downloaded file). Check if you have any dependencies requirements to fulfill, but that’s it. Pretty straight forward. Doing this, you don’t need to compile, or build your own scripts to get it started on the startup. Furthermore, you could use “service sphinxsearch (start|stop|restart|status)” to manage the daemon.

6 Comments

  1. Very shorts, simple and easy to understand, bet some more comments from your side would be great

  2. Hi Josurr,
    I will more than glad to reply any question :)
    Regards,
    Angel.

  3. I read about it some days ago in another blog and the main things that you mention here are very similar

  4. Sharan Distaffen |

    Hi there could I use some of the content from this post if I reference you with a link back to your site?

  5. Sure!

Leave a Reply