System Admin

How to install APC on Linux

PHP can be slow mainly because of code compiling on each request. That's how a request usually goes:

  • downloading the file;
  • compiling the code;
  • executing the code;
  • giving the result.

Now code is compiled on each step. To solve this problem you need a PHP accelerator.

APC is one of the most stable and easy to install PHP accelerators. APC can work in two modes configured by apc.stat parameter in /etc/php.d/apc.ini file. APC caches compiled code on the first request and then it goes this way:


  • executing the cached code;
  • giving the result;


  • checking if the file has been modified since the last cache;
  • recompilling if it has been modified;
  • executing;
  • giving the result.

apc.stat=1 mode is a bit slower because of checking file modification but it helps to avoid misunderstanding when the code is modified, but the result is still the same.

Installing APC on CentOS/RHELL/Fedora


wget -O /etc/yum.repos.d/stalwart.repo
yum install php-pecl-apc

Edit /etc/php.d/apc.ini file the way you want it.

Restart Web-server.

Installing APC on Debian/Ubuntu


apt-get install apache2-threaded-dev php5-dev php5-pear make gcc g++
pecl install apc

Add to /etc/php5/apache2/php.ini file:

Restart Web-server.


Related Articles

Leave a Reply

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