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