How to install APC on OS X (10.6)
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:
- Download the latest version of PCRE, and unpack it somewhere handy.
- Using terminal, cd to the unpacked PCRE directory.
- Run: ./configure --prefix=/usr/local
- Run: make
- Run: sudo make install
Step 3, install APC:
- Download the latest copy of APC, and unpack it somewhere handy.
- Using terminal, cd to the unpacked APC directory.
- Run: /usr/bin/phpize
- 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
- Run: make
- Run: sudo make install
Step 4, update your settings:
- 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
- Restart apache: sudo httpd -k restart
- 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!