In this article, I will explain how to install the APC opcode cache in a few easy steps, on Ubuntu 10.04.
APC is an opcode cache (and more). When a PHP script is run, it is compiled by PHP internally, before executing it. PHP does not store the compiled result, therefore, next time the script is run, PHP will compile it again. APC is designed to store the result in its cache. This way, when PHP executes again a script, APC will serve the compiled script from the cache. PHP won't have to parse the script again, and it will save a lot of time.
apt-get install apache2-threaded-dev php5-dev php-pear make
pecl install apc
APC will ask this question:
Use apxs to set compile flags (if using APC with Apache)? [yes] :
Just answer: yes
PECL will compile the APC extension and generate a apc.so extension file. We need to be sure PHP knows about this file.
/tmp/pear/temp/APC/php_apc.c:959: error: duplicate ‘static’ make: *** [php_apc.lo] Erreur 1 ERROR: `make' failed
pecl install apc-beta
cd /etc/php5/conf.d/ nano apc.ini
In the apc.ini file, write:
extension=apc.so
Finally, restart Apache:
/etc/init.d/apache2 restart