The PHP installed in OS X 10.8 is 5.3.10. We install PHP 5.4 from the php-osx project opening up a Shell and execute the following line:

$ curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4

We should link to the new php file:

$ sudo mv /usr/bin/php /usr/bin/php53
$ sudo ln -s /usr/local/php5/bin/php /usr/bin/php

We execute the following line:

$ sudo pecl install apc

Last we should insert the following lines in the php.ini:

extension=apc.so
[apc]
apc.enabled=1
apc.shm_segments=1
apc.shm_size=32M
apc.cache_by_default=1
apc.stat=1
apc.stat=7200 //2 hours