APC (Alternative PHP Cache) is a free and open source tool to cache PHP codes.
1. Install Dependency Packages for APC
yum install php-pear php-devel httpd-devel pcre-devel gcc make -y
2. Install APC using PECL (PHP Extension Community Library)
pecl install apc
Press “Enter” for the following options
Enable internal debugging in APC [no] :
Enable per request file info about files used from the APC cache [no] :
Enable spin locks (EXPERIMENTAL) [no] :
Enable memory protection (EXPERIMENTAL) [no] :
Enable pthread mutexes (default) [yes] :
Enable pthread read/write locks (EXPERIMENTAL) [no] :
If the above command fails, you can use the following method to install APC as well.
yum install php-pecl-apc -y
3. Enable APC PHP Extension
echo "extension=apc.so" > /etc/php.d/apc.ini
4. Restart Apache Service for APC
sudo service httpd restart
5. Verify APC Installation
Create a file named phpinfo.php in Apache web root directory. For example our Apache web root directory is /var/www
And add the following code to the php file
<?php phpinfo(); ?>
[Optional] If you do not have nano installed
yum install nano
Open the following url in your web browser
6. Enable PHP APC administration
Copy the following file to any web directory that you want. For example, in this case we will copy it to the web root directory.
cp /usr/share/pear/apc.php /var/www/html/
Open the file apc.phpÃÂ
In nano editor, use “Ctrl-w” to search for the username and password field to modify.
defaults('ADMIN_USERNAME','<strong>apc</strong>'); // Admin Username
defaults('ADMIN_PASSWORD','<strong>password</strong>'); // Admin Password - CHANGE THIS TO ENABLE!!!
Open the following link in your web browser.
You should see your APC stats and that’s it!