APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP library files can be fed from the parsed cache. This will generally lead to a speed increase when serving a PHP site, especially one with a lot of library files.

Install and Configure APC for PHP on Linux

First of all you need to download the APC code from the PHP PECL library.

$ wget http://pecl.php.net/get/APC

Then extract the files

$ tar -zxf APC-3.0.16.tgz

Then go to the APC Directory

$ cd APC-3.0.16

The next step is to run the “phpize” command. This requires that you have PHP development package installed. On CentOS this is php-devel (installed by running “yum install php-devel”) and it should have a similar name on other Linux distros.

$ phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20050922
Zend Extension Api No:   220051025

You then configure APC, telling it where the executable file php-config is. If you don’t know where this is, then do this:

$ whereis php-config

Once you get the php location then change the following command with your php location and run.

./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config

Then type



 make install

We are almost done now

Now just paste the following in your php.ini file


apc.enabled = 1
apc.shm_segments = 3
apc.shm_size = 256
apc.max_file_size = 10M

Now just copy apc.php from the installed folder to your web root and access the apc satus by typing

http://yourwebserver address/apc


Post By Editor (2,827 Posts)

Website: →