Neil Ang

Developer

A stunning likeness of Neil Ang
Hello world

How to install APC on OS X (10.6)

Posted on

There are two ways to install APC on OS X 10.6 (Snow Leopard). The easy way, and the manual way. Thanks goes to @j_cartledge for the tipoff on the how to do it the easy way.

Easy Install

The easiest way to get running with APC is to use homebrew. If you already have this installed, just type:

brew install apc

The brew formula may ask you to do some additional steps like update your php.ini and restart apache. Otherwise that's it.

Manual Install

Here are the steps I took to compile and install APC on my machine running OS X 10.6 (Snow Leopard). I found a lot of inconsistent information on how to install APC manually, so hopefully this will work for you.

Step 1, install Xcode if it's not already installed.

Step 2, PCRE is is a prerequisite for installing APC, so it needs to be installed next:

  1. Download the latest version of PCRE, and unpack it somewhere handy.
  2. Using terminal, cd to the unpacked PCRE directory.
  3. Run: ./configure --prefix=/usr/local
  4. Run: make
  5. Run: sudo make install

Step 3, install APC:

  1. Download the latest copy of APC, and unpack it somewhere handy.
  2. Using terminal, cd to the unpacked APC directory.
  3. Run: /usr/bin/phpize
  4. Run: MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure --enable-apc-spinlocks
  5. Run: make
  6. Run: sudo make install

Step 4, update your settings:

  1. Open (or create) your /etc/php.ini file in a text editor and add a reference to APC: extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so
  2. Restart apache: sudo httpd -k restart
  3. Test APC is installed: php -i | grep "APC"

Was this helpful? Please leave a comment if these instructions worked for you. If you needed to take alternate steps to get this installed, please leave a comment on what you did differently and what issue it resolved. Thanks!