Sunday, March 18, 2012

Installing Sphinx 2.0.4 on Ubuntu 10.04 - Lucid

This blog post will help you install Sphinx 2.0.4 on Ubuntu 10.04. 

About Sphinx
Sphinx is a distributed search engine for full text searches. While MySQL offers its own storage engine (MyISAM) for full text searches but its not easy to scale it. Sphinx has many other advantages like: 
  • better indexing and searching speed 
  • good relevance search
  • and most importantly better scalability

Sphinx has two parts:
indexer - This part indexes the data source by pulling information from it and then builds indexes. 
searchd - This part serves search queries by looking up in the index created by the indexer.

Installing Sphinx
Following steps will help you install Sphinx successfully on your Ubuntu box: 
First check if the dependencies are already installed. If not install them.
sudo apt-get install libmysql++-dev libmysqlclient15-dev checkinstall
Download Sphinx 2.0.4 in '/tmp'
cd /tmp
sudo wget 
Unpack the 'tar.gz' file and install Sphinx 
sudo tar -xzf sphinx-2.0.4-release.tar.gz
The above command will unpack the 'tar.gz' file. You can find the contents in 'sphinx-2.0.4-release' directory
cd sphinx-2.0.4-release
Make install 
sudo ./configure
sudo make
sudo checkinstall

Note: You will be prompted to create a directory and set a description for the package. Also it will ask you some questions with default answers. Fill them as per your convenience.I had an error in package installation. On checking the log file I saw that specifying version was mandatory. So changed version to 2.0.4.

After installation, the package will be saved to: 

Make a new folder to keep the *.deb package:
sudo mkdir /home/[YOUR_USERNAME]/SphinxInstalls

Move the sphinx-2.0.4_2.0.4-1_i386.deb package from '/tmp/sphinx-2.0.4-release/sphinx-2.0.4_2.0.4-1_i386.deb' to '/home/[YOUR_USERNAME]/SphinxInstalls' 
sudo mv /tmp/sphinx-2.0.4-release/sphinx-2.0.4_2.0.4-1_i386.deb /home/[YOUR_USERNAME]/SphinxInstalls

You can now delete the working folder and the tar.gz file : 
sudo rm -r /tmp/sphinx-2.0.4-release
sudo rm /tmp/sphinx-2.0.4-release.tar.gz

Location of Configuration/Daemons/Documentation
You can find Sphinx Documentation in:
Sphinx Configurations are found in '/usr/local/etc/'. The configuration files that exists by default are:
Note: Default Sphinx configuration is sphinx.conf. It is not created by default. So you can copy 'sphinx.conf.dist' as 'sphinx.conf': 
sudo cp sphinx.conf.dist sphinx.conf 
Sphinx Processes (indexer, searchd etc.) are found in '/usr/local/bin/'.

To remove Sphinx: sudo dpkg -r sphinxsearch-2.0.4
To install again use the package in '/home/[YOUR_USERNAME]/SphinxInstalls': sudo dpkg -i sphinx-2.0.4_2.0.4-1_i386.deb 

You are done with the installation of Sphinx on your Ubuntu box. In my upcoming posts I will cover Sphinx configuration (configuring local indexes and distributed instances).
^^^^ Coming this weekend

Monday, March 12, 2012

Enabling mod_rewrite Module in Apache2

I came across this situation recently and thought of publishing it on my blog so others can find it useful.

'mod_rewrite' is a module in Apache that provides a rule-based rewriting engine to rewrite requested URLs. You can read more about it at Apache Module mod_rewrite.

Enabling mod_rewrite:
To enable mod_rewrite, use the following command:

sudo a2enmod rewrite

Now restart Apache:
sudo service apache2 restart (or) sudo /etc/init.d/apache2 restart