Veerasundaravel's Ruby on Rails Weblog

June 20, 2008

Installing sphinx in linux environment

Login as root!

apt-get install build-essential gcc

# Add new system user sphinx
adduser –system –home /var/sphinx –uid 999 –disabled-password –disabled-login –group sphinx

# Create the dirs
mkdir /var/sphinx/bin
mkdir /var/sphinx/etc
mkdir /var/sphinx/log
mkdir /var/sphinx/lib
mkdir /var/sphinx/run

# Download and compile sphinx

tar -xzvf sphinx-0.9.8-rc2.tar.gz

cd sphinx-0.9.8-rc2



make install

# Install sphinx binaries
cp src/indexer src/search src/searchd /var/sphinx/bin/

# Install sphinx configuration (remember to edit as it needs)
cp sphinx.conf.dist /var/sphinx/etc/

# Copy the startup script attached below, instead of attaching I posted that file as another post (
copy that post content and save as a init script file named sphinx

mv sphinx /etc/init.d/

chmod 755 /etc/init.d/sphinx

# This shows your run level
/sbin/runlevel | cut -b 3

# Lets say it is 2…
ln -s /etc/init.d/sphinx /etc/rc2.d/S92sphinx

# Add the correct ownership to sphinx
chown -R sphinx:sphinx /var/sphinx

# Give some restrictions…
chmod -R 711 /var/sphinx/

# Ok we almost done!!
cd /var/spinx/etc

cp -p sphinx.conf.dist sphinx.conf

# And edit this entries in sphinx.conf to look like this:

sql_host                                = localhost
sql_user                                = root
sql_pass                                = (your password)
sql_db                                  = (your database name)
sql_port                                = 3306  # optional, default is 3306

# In section searchd

pid_file = /var/sphinx/run/

query_log = /var/sphinx/log/query.log

log = /var/sphinx/log/searchd.log

address =

# section index
path = /var/sphinx/lib/sphinx

Continue to edit the configuration and when you are ready…

Then start sphinx using the command!

/etc/init.d/sphinx start

now you are ready with sphinx, now you can install plugins like acts_as_sphinx, ultrasphinx etc to easily interact with sphinx using your rails application.

1 Comment »

  1. amazing… I can’t stop reading your blog, there is huge amount of interesting information… I’ll go to take my favorite tea and will return to your website.

    Thanks for the wonderful website!

    Comment by searchenginewatch — October 19, 2010 @ 10:01 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: