Wednesday, September 10, 2008

Installing the Sphinx search engine and thinking_sphinx/mysql gems on Mac OSX with XAMPP

For development, I use XAMPP for Mac OSX to run MySQL. Since XAMPP packages the binaries and library files in a virtual environment under /Applications/xampp, this presents some problems when compiling programs that depend on these MySQL files.

One particular example is when trying to install the Sphinx search engine or the mysql rubygem. The following are instructions on how to install these applications. I'm assuming that XAMPP is installed in the default directory: /Applications/xampp.

First of all, the mysql rubygem can be installed by running:

sudo gem install mysql -- --with-mysql-dir=/Applications/xampp/xamppfiles/ --with-mysql-include=/usr/local/mysql/include


And that should install the gem without any problems.

In order to install Sphinx, you'll need to compile it from source by following these instructions:

1. Visit http://www.sphinxsearch.com/downloads.html and save the latest version (0.9.8 as of this post) of the Sphinx source somewhere on your computer .

2. Run "tar xvzf sphinx-0.9.8.tar.gz" to unpack the archive, and cd into it.

3. Execute:
./configure --with-mysql=/Applications/xampp/xamppfiles/ --with-mysql-includes=/usr/local/mysql/include


4. Then run "make" and "sudo make install"


If you receive an error about expat or iconv during make, you'll need to follow these instructions to compile and install those programs from source.

At this point, you should be able to run "sudo gem install thinking_sphinx" and have it install without a hitch.

There you have it! Sphinx and the thinking_sphinx/mysql gems installed and working with XAMPP.