Install memcached and APC on Mavericks Server 3 (Mac OS X 10.9)

Dramatically speed speed up sites hosted using Mac OS X 10.9 Mavericks Server (like SocialEngine, Drupal, WordPress, or other PHP/MySQL web site) by adding APC and Memcache.

Here’s how to install APC and memcache on Mac OS X Mavericks server, which runs PHP 5.4:

OSX-Mavericks-Icon

Mavericks Upgrade Notice

If you’ve upgraded to Mavericks from an earlier version, and you’ve installed PHP extensions using MacPorts, read this article to upgrade PHP extensions for Mavericks server before continuing with this article.

Download and install MacPorts from http://macports.org.

The following steps are performed in the Terminal:

Force MacPorts to update:

sudo port -v selfupdate

Building memcached

Build the PHP 5.4 version of memcached:

sudo port install php54-memcached

Set memcached to load on startup:

sudo port load memcached

Building APC

Build the PHP 5.4 module for APC (Alternative PHP Cache):

sudo port install php54-apc

Add to php.ini

Next, you need to edit php.ini to add the extensions. Find the phrase Dynamic Extensions, and add:

extension=/opt/local/lib/php54/extensions/no-debug-non-zts-20100525/memcached.so
extension=/opt/local/lib/php54/extensions/no-debug-non-zts-20100525/apc.so

And finally, restart Apache:

sudo apachectl restart

To confirm installation, create a new PHP document called phpinfo.php with the following contents:

<?php
  phpinfo();
?>

Point your browser to that file. If all went well, you’ll see these blocks:
php54-apc-memcache