Installing Sphinx and PECL/Sphinx on Mac OS X

by Sam Holman, Wednesday January 12 2011

I’ve got a fairly vanilla install of Snow Leopard (10.6) and use the default installations of PHP, MySQL, Apache, et al. Installing the Sphinx open source search engine and the PECL extension wasn’t too much of a pain, but would have been easier had i had the following notes to hand. :-p

I first tried installing through Macports, but as usual, this wanted to install MySQL5 as a dependency, which would have been a duplicate of the MySQL that i already have so decided not to go ahead with that.

So to manually install, first step is to head to the downloads page at http://sphinxsearch.com/downloads/ and grab the source tarball for the version you wish to use. Unpack it, open a terminal and cd to the new directory, configure and install as normal. In my case,

wget http://sphinxsearch.com/files/sphinx-1.10-beta.tar.gz
tar -zxvf sphinx-1.10-beta.tar.gz
cd sphinx-1.10-beta
./configure
make
sudo make install

That was fairly simple, but if you try to install the PECL extension now then it'll probably result in an error:

checking for libsphinxclient headers in default path... not found
configure: error: Cannot find libsphinxclient headers
ERROR: `/tmp/sphinx/configure --with-sphinx' failed

So you must also install the libsphinxclient libraries separately. For some reason the configure script for this expects your C++ compiler to be in /lib, which doesn’t exist on OS X:

configure:5515: error: C++ preprocessor "/lib/cpp" fails sanity check

Thankfully we can get around this too:

cd api/libsphinxclient
CXXCPP="gcc -E" ./configure
make
sudo make install

We can now install the extension with PECL:

sudo pear install pecl/sphinx

Finally, add extension=sphinx.so to your php.ini if appropriate and you should be good to go.

php -i | grep sphinx

confirms:

sphinx
sphinx support => enabled

« Back to blog index

Add a comment

Or perhaps another recent post might interest you?

Welcome to our blog

This is where we talk about design, development, our products and our company.

Subscribe to RSS

Choose a category:

What we're listening to:

Recently played tracks

Taking our early ideas Label Media have been able to supply us with exactly the product we were hoping for...

Wakefield Metropolitan District Council Cultural Services.

Start your project today

Fill in our quick enquiry form and we'll get back to you shortly.

Make enquiry