Installing Alternative PHP Cache (APC).


Written by Pavs on June 19th, 2008

Some time ago I wrote a howto on installing xcache for linux (here) from source. While xcache requires a certain amount of learning, tweaking and configuration to get it right. For instance, you will have to manually edit xcache config for number of processors/cores used in your system; which will reflects other aspects of the configurations, depending on the memory available to you. This is also true if you install it from repo. What we need is a quick solution to your php bytecode optimization with minimum configuration.

Enter APC- Alternate PHP Cache.

APC is a rather new project and works on PHP version 5.2 onwards. APC is also set to be included with PHP6 as a feature rather than as an addon, as it is currently used. APC can be easily installed with PECL package manager and installer. The obvious requirement for APC to be installed, is that you have apache2-dev, php5-dev and php-pear installed.

On Debian system you can install them like this: sudo apt-get install apache2-threaded-dev php5-dev php-pear

On fedora based Yum installer: yum install php-pear php-devel httpd-devel

Furthermore: yum groupinstall ‘Development Tools’ and yum groupinstall ‘Development Libraries’

After all the dependencies are installed. The next line is universal in all systems, as long as you have php-pear installed.

sudo pecl install apc

After the installation is complete you will be asked to edit the php.ini to add one line (”extension=apc.so”), and your APC is ready for action.

Restart your apache server and check (php -v) to confirm that the module has been properly loaded.
While it is matter of debate among php bytecode optimizer fanboys (yes, even they have fanboys), as to which one is the best optimizers of them all, the speed difference among the top three optimizers (APC, Xcache and Eaccelerator) are very little to argue about. Yet the perfectionist among you might be interested in the extra 2 pages per second load time. To me, it boils down to difficulty in installation and configuration on an existing system. Presently APC seems to have the upper-hand, with the integration of APC and php6 it might make deployments of other bytecode caches obsolete. Till than, we do it the hard way.




Subscribe without commenting


Leave a Reply

Note: Any comments are permitted only because the site owner is letting you post, and any comments will be removed for any reason at the absolute discretion of the site owner.