Quick Overview of Alternate PHP Cache (APC)

APC stands for Alternate PHP Cache. It is an open source caching module to cache PHP codes and thereby optimizing it. With this caching enabled in the server, PHP code will be cached and it will be served faster from then on without having to re-run the code.

Installation & Configuration of APC

One of the shortcomings of APC is that it won’t work with suPHP. So we need to install FCGI and make it the default PHP handler.

You can install FCGI by running easyapache. And for making FCGI, the default handler, goto:

Home >> Service Configuration >> Configure PHP and SuExec

Select CGI from the PHP 5 Handler drop down and Save New Configuration.

With this, pre-requisites of installing APC is complete.

For installing the APC cache, we need to install the dependency packages first.

yum install php-pear php-devel httpd-devel pcre-devel gcc make

With the dependencies installed, we can simply install APC with PECL. PECL is PHP Extension Community Library which contains the PHP extensions. PECL should be already in the cPanel servers along with the cPanel installation.

pecl install apc

A few questions will be prompted pre to installation. You can go with the recommended default option. SO, just hit ‘Enter’ for each one. You may refer the screenshot below.


This will enable the APC extension by mentioning the extension in the PHP configuration file (php.ini).


You can modify the APC functionality by editing the apc.ini file. By default this file is not created in cPanel servers. So we can edit the parameters in php.ini itself. The following command gives you php.ini file.

php -i | grep php.ini

The output can be referred from the screenshot.

The loaded configuration file is /usr/local/lib/php.ini by default in cPanel servers, So we can add the APC parameters in the PHP configuration file.

Here are a few recommended APC parameters:

 #Enable/Disable APC
 #Number of Memory segments (RAM) used by APC (It only uses 1 shm_segment, so you can set it as 1 or remove it)
 #Number of storage space (RAM) allocated for APC (Default is 32 MB)
 #APC Max file size
 #Number of Opcode files stored in APC (default is 1000, you can increase values for more performance)

If you need to customize APC, you can add the values as mentioned above and make sure you restart apache after the changes.

/etc/init.d/httpd restart

You have APC installed and enabled now.

We hope you have found this tutorial useful on how to install APC cache on a cPanel Server

Thanks for reading and leave your questions below to keep the conversation going.

Leave a Reply

Your email address will not be published.