Install memcache and APC on Mac OS X Server (snow leopard 10.6, Lion 10.7, Mountain Lion 10.8)

Looking to speed up your SocialEngine, Drupal, or other PHP/MySQL web site? The combination of APC and Memcache can really speed up sites based on these platforms. If you’re an admin of a server running Mac OS X Server (10.6), here’s how to install APC and memcache on Mac OS X server:

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

OSX-Mavericks-Icon

Mavericks Instructions

If you’re running Mac OS X Mavericks Server, see these articles about adding PHP extensions:

If you’ve previously installed this extension using instructions on this page, read this article to upgrade PHP extensions for Mavericks server.

The following steps are performed in the Terminal:

Force MacPorts to update:

Installing memcached and php5-memcache

Now, install memcached:

Set memcached to load on startup:

Install the PHP5 module for memcache:

Copy the newly created shared object for memcache into Mac OS X’s default PHP5 extension directory:

Installing php5-apc

Install APC (Alternative PHP Cache):

Copy the newly created shared object for APC into Mac OS X’s default PHP5 extension directory:

Adding memcache and apc to Apache

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

And finally, restart Apache:

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

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

6 thoughts on “Install memcache and APC on Mac OS X Server (snow leopard 10.6, Lion 10.7, Mountain Lion 10.8)

  1. I know this is an old thread, but it’s right on track for my PowerPC G5 based os x web server. I followed the steps above, and everything seems to have worked fine. However, only memcache is showing up in the info.php output — APC isn’t there. The version of php.ini in /usr/local/php5/lib/ appears to be the one showing up when I load info.php, but just to check it, I also added the extensions to /etc/php.ini. Still I get no APC blocks showing up after restarting apache.

    Any advice?

  2. Additional note: because it’s a G5 machine, I’m running osx leopard server. Macports seems to have compiled the ppc versions, so I’m not sure why this would matter.

  3. making cup of coffee: 4 minutes
    installing memcache & APC : 3 minutes

    now looking for an APC for my coffe machine and i’m in bussines

    tnx !

  4. Pingback: Install memcache and APC on Mavericks Server 3 (Mac OS X 10.9) | Garbage In Garbage Out : Tech Blog

Add Comment Register



Leave a Reply