We're at a point in web design where speed matters more every day. It matters to google because a slow site gets penalized, and it matters to your client because they have other things to do. All of these things mean less business, so you want to keep your site as nimble as possible.
Installing PHP's APC opcode cache in Ubuntu is fairly simple, and extremely useful. PHP is a dynamic server side language, that generally means that when somebody accesses your site, the PHP file being requested has to be read, compiled, and then executed. This happens on every single page request, so the process is not only slower, but allows for less concurrency, and that means less people can be guaranteed a pleasant stay on your website. APC stores the result of the compiling and executing in memory, and provides that instead when the file in question is requested, saving your server a great deal of effort.
First, we have install the PEAR package manager, if you have that installed you can skip this step.
sudo apt-get install php-pear php5-dev make libpcre3-dev
With PEAR installed, we can go ahead and install APC
sudo pecl install apc
Using all the default values during installation is fine. You can always come back to them if you're finetuning them in the future. Now we need to let PHP know that we've installed a new extension by editing our php.ini file, for Apache users it's usually located at /etc/php5/apache2/php.ini, you can open it an editor like vim or nano and add the following two lines at the bottom
extension = apc.so
apc.shm_size = 64
The first line enables APC to run as a PHP extension, and the second value tells APC how much memory to store the cache in. This example uses 64MB, you can adjust it at any time to suit your needs and constraints.
To finish, all you have to do is restart Apache by running:
service apache2 restart
APC is now enabled and working, you should notice a significant performance boost if you're running any Drupal website that is fairly elaborate. For more information you can check out the PHP Manual on APC. Drop us a line if you have any questions!