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
GDRafael (not verified)
I was having problem to
Fri, 2011/03/04 - 08:32I was having problem to install APC via 'pecl' cause I didn't install the 'pcre-devel'.
This was very helpful! Thank you very much guys! :)
Visitor (not verified)
Same - Thanks. It solved my
Thu, 2011/12/08 - 09:36Same - Thanks. It solved my problem
Zahir (not verified)
yum install pcre-devel did
Tue, 2011/04/26 - 15:54yum install pcre-devel did the trick. APC installed.
In phpinfo() apc shows as one of the modules but none of the variables like those below show.
apc.enabled=1
apc.shm_segments=1
apc.optimization=0
apc.shm_size=32
apc.ttl=0
#apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/XXXXXX
apc.enable_cli=1
apc.cache_by_default=1
How do we know its installed and working? Also, we located apc.php but executing it in a browser gives us 500 error
Thanks a ton
Matt (not verified)
This did the trick. Thank
Sat, 2012/01/14 - 14:09This did the trick. Thank you!
Visitor (not verified)
A video tutorial would be
Sun, 2011/10/16 - 11:19A video tutorial would be greatly appreciated as I'm sure there are many newbies such as myself who don't have the slightest idea how to work this.
Between google, dealing with a hosting helpdesk who is losing his/her patience, and my own complete frustration with trying to figure this out, I am requesting a video tutorial please.
justin namara (not verified)
pblm make install
Thu, 2011/10/20 - 10:53make: *** [apc.lo] Erreur 1
ERROR: `make' failed
[root@ks32755 ~]#
for : pecl install apc
:/
Levani (not verified)
problem
Wed, 2012/01/04 - 06:48Can't run the first command successfully. Here is what I get:
What do the last two errors mean and how should I fix it?
Bidi (not verified)
The upload is working but the
Fri, 2012/06/22 - 17:17The upload is working but the progress bar is remains at 0% what can i do ? :( please help
Matteo (not verified)
You don't mention that when
Fri, 2013/04/12 - 14:55You don't mention that when you run:
pecl install apc
you are asked a question (or maybe it's just the first of a series):
Enable internal debugging in APC [no] :
What does that mean and what are the pros and cons of replying "yes" or "no" ?
Khalid
Hit enter
Fri, 2013/04/12 - 17:45You just hit enter. The default is fine.
But, this was for an older version of Ubuntu. The latest version (12.04) has a php-apc package that works well, with no need to install using pecl.
Pages