APC on a WHM/CPanel Server

One of my clients needed APC installed for their application, so I initially tried to install it via WHM module installer …. this failed.   Here are the steps that I took to get it working via CLI
First download the newest stable release of APC and then run the following commands.

wget http://pecl.php.net/get/APC-3.1.6.tgz
tar -xzf APC-3.1.6.tgz
cd APC-3.1.6
which php
phpize

If you do not have pcre installed the make install will fail.  So make sure to run the following yum command to install it with the development packages for safe measure.

yum install pcre.i386 pcre-devel.i386

This is the configure line that I used, your php-config location MIGHT be different so make sure to double check that

./configure –enable-apc –enable-apc-mmap –with-apxs –with-php-config=/usr/bin/php-config
make
make install

Lastly find the correct php.ini that your system is using and then edit that ini and add the following config settings near the end of your php.ini.

php -i | grep php.ini
vi /usr/local/lib/php.ini

Config to add before the “zend” section.

extension=”apc.so”
apc.enabled=”1″
apc.shm_segments=”5″
apc.shm_size=”16″
apc.ttl=”7200″
apc.rfc1867=”on”
apc.mmap_file_mask=”/tmp/apc.XXXXXX”
apc.user_ttl=”7200″
apc.num_files_hint=”2048″
apc.enable_cli=”1″
apc.max_file_size=”10M”

I also ran into an issue that when the apc.so was compiled it was not placed in the proper extension_dir, I had to manually copy it to the correct folder.  Once you have done all that stop and then start Apache and walla you should be all set.  check your php.ini to make sure APC shows up.