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.
See also:
- How to install and configure Nginx, PHP-FPM and APC on Debian
- How to install Nginx, PHP 5.3.10 and PHP-FPM on CentOS 5.7 — 6.2
- How to install LAMP (Linux, Apache, MySQL, PHP) on CentOS
- How to fix "upstream timed out (110: Connection timed out) while reading" error in Nginx and PHP-FPM
- How to enable gzip compression on Apache
- How to build Highly Available LAMP on Ubuntu
-
ctman2013-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!!
-
2013-04-02 20:55:58
On Debian/Ubuntu there is a package to intall called: php-acp
-
2013-07-10 11:18:42
lol
Got a comment?
All Rights Reserved.