Rebuilding PHP extensions to work with Mac OS X Mavericks server and PHP 5.4

Because Mavericks server uses PHP 5.4, any extensions you may have compiled for previous versions of Mac OS X (such as memcache, apc, mcrypt) need to be recompiled and reinstalled.

This post assumes you used MacPorts to compile and install the PHP extensions in question. Here’s how to accomplish the task:

Force MacPorts to update from the terminal:

Next, determine which ports depend on the php5 port:

After visually confirming you want to get rid of them all, issue this command to uninstall the old versions of those ports:

Do the same for memcached (if you’ve installed it):

Now unload it:

Compiling the new PHP  5.4 version

Now, we need PHP 5.4 in order to build our extensions. So, let’s install the PHP 5.4 port:

Back up your existing /etc/php.ini file if you have one:

Copy the php.ini file from the new port to your /etc/ directory. Choose the version (development or production) that suits your requirements:

Duplicate any modifications you made in your original php.ini.orig file in your new /etc/php.ini file.

Compiling new versions of PHP extensions

Now, use MacPorts to download and recompile your PHP extensions: