12
Build and install APC extension on Mac OSX 10
If you tried to install the APC extension on the MAC and got the following error:
pecl mac error: ‘apc_regex’ has no member named ‘nreg’
The problem is that APC depends on the PCRE library and we need to install it before compiling APC. Here is how to fix it!
- Open a TERMINAL session, type : mkdir temp
- Head up to this page and download a PCRE library (try to use the latest one). I took pcre-8.12.zip, put the file inside the temp directory
- uncompress the PCRE archive via Finder (or any other way)
cd pcre-x.xx replace x with the version number (example: cd pcre-8.12)
./configure
make
sudo make install
- now download the latest APC release (link here)
- uncompress the APC archive via finder (or terminal by typing   tar zxf APC-X-XX replace X with archive name and version number )
- type
cd ~/temp/APC-3.1.9Â Â Â (change the version number if you're using something different)
phpize
./configure
make
sudo make install
you should see something similar to this when it’s done compiling
Installing shared extensions:Â Â Â Â /usr/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files:Â Â Â Â Â Â Â Â Â /usr/include/php/
Modify your php.ini file to have the extension loaded at php startup
- Open /private/etc/php.ini  (in Finder, select GO menu, select GO TO FOLDER and type /private/etc)
- add this line in the Dynamic extensions area
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/apc.so
Restart the web server (reboot your machine if your lazy, or go into the System preferences, click on Sharing, un-select Web sharing , wait a few seconds and select it again )
You’re done, congrats!
Note:
There is a bug in version APC 3.1.9Â
if you get error
Fatal error: Unknown: apc_fcntl_unlock failed: in Unknown on line 0
Relax! just modify the file apc_lock.h inside the APC folder you created. Edit the following line around lines 155-160
Find the following:
# define apc_lck_rdunlock(a) apc_fcntl_unlock(&a TSRMLS_CC)
Replace by the following
# define apc_lck_rdunlock(a) apc_fcntl_unlock(a TSRMLS_CC)
Recompile APC by doing:
cd ~/temp/APC-x-xx (replace X with version number) make clean phpize ./configure make sudo make install
And restart your web server! Too easy ! enjoy!








thanks for the tip, this worked perfectly
Great tutorial except that a “./configure” is missing between “phpize” and “make” in APC installation in the first part.
you’re right! merci Julien!
Wow, these are great instructions. It totally worked. That’s the first time I’ve ever compiled an extension for PHP. This was a great tutorial for me go through. I learned so much.
Thanks again.
When expanding APC-3.1.9.tgz with the Finder you get a folder called APC-3.1.9 which contains another folder called APC-3.1.9 and a file called package.xml. You need to do a cd to ~/temp/APC-3.1.9/APC-3.1.9 before you do phpize otherwise it will not work. Except for this, this is great and APC got installed. Thanks a lot, now up to this progress bar.