The APC extension should be a straightforward PECL install, but sadly it does not work on Mac OS X Lion. Attempting to install will result in make errors similar to the following:
In file included from /private/tmp/APC/apc.c:44: /usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory In file included from /private/tmp/APC/apc.c:44: /usr/include/php/ext/pcre/php_pcre.h:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token /usr/include/php/ext/pcre/php_pcre.h:38: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token /usr/include/php/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before ‘pcre’ /private/tmp/APC/apc.c:393: error: expected specifier-qualifier-list before ‘pcre’ /private/tmp/APC/apc.c: In function ‘apc_regex_compile_array’: /private/tmp/APC/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’ /private/tmp/APC/apc.c:454: error: ‘apc_regex’ has no member named ‘preg’ /private/tmp/APC/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’ /private/tmp/APC/apc.c:455: error: ‘apc_regex’ has no member named ‘nreg’ /private/tmp/APC/apc.c: In function ‘apc_regex_match_array’: /private/tmp/APC/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’ /private/tmp/APC/apc.c:487: error: ‘apc_regex’ has no member named ‘preg’ /private/tmp/APC/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’ /private/tmp/APC/apc.c:488: error: ‘apc_regex’ has no member named ‘nreg’ make: *** [apc.lo] Error 1 ERROR: `make' failed
Thankfully, the solution is simple. APC requires PCRE libraries and header files to be available, so we can download and install these from source:
- Download the latest PCRE from http://sourceforge.net/projects/pcre/files/latest/download?source=files
- Unzip the file
- cd into the unzipped
pcre-directory and then type:
./configure make sudo make install
Next, we can install the APC extension using the normal PECL route:
sudo pecl install apc
Confirm that you have the following line in your php.ini file:
extension=apc.so
Restart Apache, if required:
sudo apachectl graceful
You should now have APC available, and you can confirm this by looking at your phpinfo output:







