Installing sphinx PHP extension on Mac OS X

Installing Sphinx’s PECL PHP extension is not that easy on Mac OS X and hopefully the following will save you a few hours 😉

First, you’ll need to download the latest Sphinx source from the official website. Uncompress the tarball archive and go to the folder :

> cd ./api/libsphinxclient
> CXXCPP="gcc -E" ./configure --prefix=/opt/sphinx
> make
> sudo make install

You should now be able to install Sphinx’s PECL extension :

> sudo pecl install sphinx

The installation program will ask you where the libsphinxclient headers are located. Just tell him where you just installed them:

Please provide the installation prefix of libsphinxclient [autodetect] : /opt/sphinx

If everything goes well, you’ll just have to activate the extension in your PHP.ini file by adding the following :


Note: if you installed PHP with MacPorts, your php.ini file is at the following place :


If the file doesn’t exist, you should have a php.ini-development and a php.ini-production file in /opt/local/etc/php5. Just copy the on you want. Ex:

/opt/local/etc/php5> cp php.ini-development php.ini

That’s it! Restart Apache and your sphinx extension should be available.

Leave a Reply

Your email address will not be published. Required fields are marked *