Complex PHP applications, such as Drupal, can gain a lot of performance benefits from running a PHP op-code cache/accelerators.
APC,
Alternate PHP Cache, is now the most maintained free/open source op-code cache, and is being used more and more as it emerges to be the
most stable.
The instructions here detail how to get APC running on a CentOS 5 server. The server happened to have Plesk on it as well, which initially made me hesitant to install APC "normally", since Plesk is so picky on what other software is installed on the server. However, it seems to have worked out well.
First, we need the pecl command so we can download and install APC from the repositories.
Do to so, we execute the following command:
yum install php-pear
But, this will not run on its own, we need the following package for the phpize command:
yum install php-devel
We also need the apxs command, which is installed via the following package:
yum install httpd-devel
Now we have all the software we need, so we install apc via the pecl command:
pecl install apc
Once that finishes, we need to enable apc in Apache's configuration. the following command should do this for us.
echo "extension=apc.so" > /etc/php.d/apc.ini
Then we restart Apache:
/etc/init.d/httpd start
And we are all done. Watch for less execution time per page, and decreased memory usage per Apache process compared to what you had
before.
Links
You can find some additional tips at Setting up Alternative PHP Caching APC support on Centos server.
Comments
Visitor (not verified)
module issue
Sat, 2013/10/12 - 16:28I'm getting this after fiddling trying to get APC up and running
Any ideas MUCH appreciated.
Peg (not verified)
How do I specify what version of APC I am instaling
Mon, 2014/05/05 - 19:41I need to be sure that I am installing either APC 3.0.19, 3.1.3p1 or 3.1.9.
Do I add something to this comand?
pecl install apc
Khalid
Latest will be installed
Mon, 2014/05/05 - 19:55You just use the command:
pecl install apc
And the latest will be installed for you.
Peg (not verified)
I actually do not want the
Mon, 2014/05/05 - 20:04I actually do not want the latest version. The software that I am using and need to speed up said not to install the latest version because it was quirky.
Khalid
Odd ...
Mon, 2014/05/05 - 20:09That is odd, but you can try:
pecl install apc-version
or
pecl install apc-version/beta
Replace "version" above by the specific version you want installed.
oliverusselldev (not verified)
php apc or memcached
Fri, 2018/08/31 - 06:43When comparing PHP APC with Memcached, which one is better to be used on your server? I have used Memcached on my server because the platform I am using to host PHP website has it by default in the stack. I am satisfied with the performance, but if APC is better than I would like to try it out as well.
Khalid
Different things
Fri, 2018/08/31 - 10:05These are two different things. One is for code caching, making execution of code faster, and the other is for data and page caching.
You need them both.
Pages