Alternative PHP Cache – APC

By | September 26, 2011

The “Alternative PHP Cache” (APC) is a free and open opcode cache for PHP. It was designed to provide a free framework, open and robust for caching and optimizing PHP intermediate code. It is known that APC should normally be included an alternatively in php icon wink Alternative PHP Cache.

We should use it to optimize the access of portals, and it is true that the improvement is really important!

Here is a small howto explaining how to install an APC on debian with php4.

First you need to install PEAR
apt-get install apache2
apt-get install libapache2-mod-php4
apt-get install php-pear
apt-get install php4-dev
apt-get install make
pecl install apc

You must install the mod pre-fork as well. Otherwise apache2-prefork-dev will show an unnecessary error, “Sorry, not able to successfully run APXS. ”

You must copy the file / usr / share / php / apc.php and make it available via a web interface, eg / var / www / htdocs /
And you must edit the file to include a password
vi / var/www/apache2-default/apc.php
To change this password you must change these values:
defaults (‘ADMIN_USERNAME’, ‘user’) / / Admin Username
defaults (‘ADMIN_PASSWORD’, ‘password’) / / Admin Password – Change to Enable this..

Then you must edit the php.ini file and add this:
extension = apc.so
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 1024
apc.max_file_size = 1024000

apc.enabled enable or disable APC. It is a default
apc.shm_segments is the number of memory segments to allocate for the cache. It is a default.
apc.shm_size is the size of each shared memory segment in MB. This must be paid according to the machines capabilities and needs.
apc.max_file_size prevents large files from being cached.

It is possible to clear the cache by authenticating and clicking on ‘Clear Cache opcode ”

And experience the greatly improved performance with alternative PHP Cache.

Leave a Reply

Your email address will not be published. Required fields are marked *