Installation of APC on php 5.3 (CentOS 5.x)

My previous blog entry used Eaccelerator as a php cache, but it does not appear to be actively maintaned.

In my research for a suitable and robust alternative, I recognized that a lot of large sites were using APC, and it was compatible with my desired application (Moodle)

APC (Alternative PHP Cache) is a free, open, and robust framework for caching and optimizing PHP intermediate code. (taken from:
In order to avoid installation conflicts from the base repository, it was much simpler to compile the APC package from source for the php 5.3 on a CentOS 5.x installation.

0. Login as root

1. Go to temp folder and download the latest tarball cd /temp

2. Extract to temp
tar xzvf APC-3.1.9.tgz
cd APC-3.1.9

3. Configure and Install
**amended on 05-07-2012, added pcre-devel install as suggested by yaroslav.

yum install pcre-devel 

make test
make install

4. Create APC config filenano /etc/php.d/apc.ini
Add to file
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64M
apc.max_file_size = 10M

Further information on advanced tweaking of configuration items here:
5. Restart the webserver
service httpd restart

6. Check to see if APC was installed properly
nano /var/www/html/phpinfo.php

Add to file

< php
Save and Exit

Launch from web browser:
The APC configuration item should be found on the page.

7. Install the APC monitor

Copy APC Monitoring file into web root
cp /temp/APC-3.1.9/apc.php /var/www/html/

(There are options to secure this file, see the website for further details:

Check the APC monitor

Launch from web browser:
*A page should load displaying cache information and host status.

That’s it. A quick and painless method of installing the APC Cache for php 5.3 on CentOS 5.x.


5 thoughts on “Installation of APC on php 5.3 (CentOS 5.x)”

  1. Dear Pretend Chef

    You cooked up a tasty and sumptuous dish in this easy to follow tutorial. How I wished that this blog entry, with your lucid instructions on APC and PHP/Apahce existed one year ago when I was configuring eAccelerator for my VPS! Keep up the good work and keep up cooking these kind of dishes!

  2. Thank you Frankie, I'm currently doing some research into moving from Moodle 1.9 to 2.2. These are the little prerequisites I'll need in my test, so I thought I'd document it all as I go along.

    Did you make the move to Moodle 2.x yet?


Comments are closed.