Installing APC op-code cache on Ubuntu 10.04
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.
First step: install PECL
apt-get install apache2-threaded-dev php5-dev php-pear make
Second step: install APC
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
then you might have to retry with a newer version of APC (as of July 2010, the latest stable version of APC does not completely support PHP 5.3 it seems).
Try this instead:
pecl install apc-beta
Third step: enable the extension
cd /etc/php5/conf.d/ nano apc.ini
apc.ini file, write:
Finally, restart Apache: