Referred web sites:
- http://www.php.net/manual/en/book.apc.php
- http://php.find-info.ru/php/016/ch20lev1sec1.html
- http://linuxaria.com/howto/everything-you-need-to-know-about-apc-alternate-php-cache?lang=en
- http://lampzone.wordpress.com/2010/03/26/how-does-apc-work/
What is APC ?
- APC is stands for Alternative PHP Cache
- APC is a free and open opcode cache for PHP
- Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.
Who need APC ?
- System Administrator who need increase the performance of a PHP web site.
- Web designers/developers or programmers who develop web applications using Yii,WordPress,Drupal or any framework.
How can I find more information about APC ?
- You can read about apc on http://www.php.net/manual/en/book.apc.php
How APC works ?
- First of all, You need to know how a PHP application run by the Zend Engine (Opcodes and Op Arrays)
- The first step is reading the PHP code from the filesystem
and put it into memory.
- Lexing : The php code inside is converted into tokens or
Lexicons.
- Parsing : During this stage, tokens are processed to derive
at meaningful expressions.
- Compiling : The derived expressions are compiled into
opcodes.
- Executing : Opcodes are executed to get the final result.
- The goal of APC is bypass the steps from 1 to 4, caching in a shared memory segment the opcodes generated and then copies them into The execution process so Zend can actually execute the opcodes.
How to install APC ?
Install APC from a repository of your distribution.
- On Debian and Ubuntu APC is available on the main repository with this name:
sudo apt-cache search apc php
php-apc - APC (Alternative PHP Cache) module for PHP 5
sudo aptitude install php-apc
On Red Hat Enterprise, Centos or Fedora you can use this command:
sudo yum install php-pecl-apc
APC configurations
- Once installed APC must be enabled in the configuration file of PHP: php.ini, if you have installed APC from a package this is already done and you just have to restart Apache (or FastCGI daemon like FPM) to see a new APC section in phpinfo() which will confirm it’s enabled.
- Otherwise you have to include in your php.ini this line:
extension=apc.so
How to set APC runtime configuration ?