Installing PHP Couchbase extensions and libcouchbase on Mac

Following the instructions from and didn’t work for me. When using the next version, with libcouchbase installed the recommend way (the way I show you not to do it below), I got this error when using their precompiled binary:

I tried using the latest version of libcouchbase (also shown below); there were no more startup warnings, but the extension was just not showing up in the modules list. Next, I switched to using the precompiled binary from the current version. Again, no PHP startup warnings, but the extension was just not showing up. So, I poked around and found this combination that works on both OS X 10.7 and OS X 10.8.

We simply need to install the latest version of libcouchbase and then compile the Coucbase PHP extension ourselves.

First off, do not do:

This will installs the wrong version and you’ll see an error like this when you get to the ./configure step.

Instead, install the latest version of libcouchbase, and get the couchbase php extension source code and compile it:

Then, register the couchbase extension by adding the following to your Mine is /etc/php.ini.

Now, you can confirm that PHP is loading this new extension by doing:

You should see couchbase in the list of modules. If you see it there, everything has gone according to plan.  If it doesn’t show up and you see no startup warnings, you can try specifying the extensions path explicitly.

Lastly, restart Apache

and double check that the couchbase module is being shown when you do a phpinfo();


Installing PHP 5.4 with MacPorts

I had a little bit of a run around trying to figure this out. So here’s the full process, all in one place for your convenience. This assumes that you have MacPorts installed, but if you don’t, there are several ways of doing so.

Before we get started, be sure to disable OS X’s default Apache install if you haven’t done so already.  This can be done by opening System Preferences, going to Sharing and disabling Web Sharing.

If you don’t care about the explanation, skip to the bottom.

Let’s get started. Open Terminal, and paste the following:

This will install Apache2 and PHP 5.4, and setup Apache to start on boot.

Next, configure Apache to use PHP 5.4. Create the file /opt/local/apache2/conf/extra/php.conf,

And paste the following into it:

This will load the PHP 5.4 module, make index.php the default directory index file and cause files with .php and .phtml extensions to be interrupted by said PHP module.

Next, tell Apache to include your new PHP config file. Open the httpd.conf,

And add this line to the bottom:

Lastly, restart Apache.

You should now have a functional PHP 5.4 environment. Also, don’t forget that you’ll need to reinstall all of your favorite PHP modules. Here’s what I normally roll with. Don’t forget to restart Apache again.

TL;DR: If you have su access, you can just copy and paste the whole thing all at once: