APC cache is a PHP caching solution which stands for Alternative PHP Cache. It serves PHP pages from a cache thus helping to reduce server load. APC is an open source software and is updated from time to time.
The following are the steps to install APC cache on a CentOS server OR even on a cPanel and Plesk server. All these commands are executed via SSH as a ‘root’ user.
1) Firstly, goto a temporary directory
# cd /usr/local/src
2) Download the latest APC version
# wget http://pecl.php.net/get/APC-3.1.6.tgz
3) Unpack the version and change to the APC directory
# tar -zxf APC-3.1.6.tgz # cd APC-*
4) Create configuration files
5) Search for the “php-config” file since you need to configure APC with it
# which php-config
Now, configure APC
./configure --enable-apc --enable-apc-mmap --with-apxs \ --with-php-config=/usr/local/bin/php-config
7) Create the installation files and install APC
# make # make install
Now that the APC cache is installed on your server, the final step is to activate the APC extension in the php.ini file. Locate the working php.ini file and edit it
# php -i | grep php.ini
Search for “extension_dir” and place the following code under it:
extension="apc.so" apc.enabled=1 apc.shm_segments=1 apc.shm_size=256 apc.ttl=3600 apc.user_ttl=7200 apc.num_files_hint=1024 apc.mmap_file_mask=/tmp/apc.XXx apc.enable_cli=1
Save the file and restart the Apache web server. You can tweak the APC settings by editing the above file but make sure you restart the Apache service for the new changes to take affect.
That’s it. To check if APC is activated, execute
# php -i | grep apc
Note: once APC is installed, make sure the ‘apc.so’ file is created under the directory specified at the “extension_dir” in php.ini. If not, look for the exact path of the file and create a symlink under it.