Installing PHP accelerator 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:

apc.stat=0

  • executing the cached code;
  • giving the result;

apc.stat=1

  • 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

Run:

wget http://rpm.scwlab.com/el/php/yum.conf -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

Run:

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

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

extension=apc.so

Restart Web-server.






  1. ctman
    2013-02-05 18:22:59
    I tried repeatedly to install APC accelerator on  Fedora 16 using the above code and some other code  I found on the web. None of them worked. Problem with the repo. I finally discovered that I could install APC via the "Add/Remove Software" function in Fedora's "Administration" menu. That worked!! 
  1. 2013-04-02 20:55:58
    On Debian/Ubuntu there is a package to intall called:
    
    php-acp
    
    
  1. 2013-07-10 11:18:42
    lol

Got a comment?

captcha =

Categories

  1. System (20)
    1. FreeBSD (5)
    2. Linux (9)
  2. Email (2)
  3. DNS (2)
  4. Databases (1)
  5. WebServer (27)
 
Copyright © 2012-2015 HowToUnix - *nix Howtos and Tutorials
All Rights Reserved.