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:

1

brew install libcouchbase

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

1

2

3

4

5

6

configure:error:

It appears you are using libcouchbase1.x

ThisDP version of the php extension supports libcouchbase-2.0.0beta

orhigher.Either useastable1.0version of the php extension,

upgrade your libcouchbase,orspecify the location ofa

libcouchbase-2.0.0installation with--with-couchbase

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 php.in. Mine is /etc/php.ini.

1

extension=couchbase.so

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

1

php-m

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.

1

extension=/path/to/couchbase.so

Lastly, restart Apache

1

sudo apachectl restart

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

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.

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,

1

sudo vi/opt/local/apache2/conf/httpd.conf

And add this line to the bottom:

1

Include conf/extra/php.conf

Lastly, restart Apache.

1

sudo/opt/local/apache2/bin/apachectl-krestart

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.