APC only works upto PHP 5.4 and does not work with PHP 5.5 and PHP 5.6.
The quickest way to install APC for PHP 53 or PHP 54 is through Litespeed repository. Enable Litespeed repo and yum install lsphp53-apc or yum install lsphp54-apc. you will need lsphp53, lsphp53-common or lsphp54, lsphp54-common to make it work. see instruction here.
You can also compile/install for Linux, OS X, FreeBSD, Solaris, etc.
APC is a very mature opcode-caching module, aka “php accelerator”, and strongly maintained at http://pecl.php.net/apc. We highly recommend APC for anyone using php scripts.
Download and extract source from http://pecl.php.net/package/APC.
Make sure version 3.0.11 or higher is used. Starting with 3.0.11, –enable-apc will imply –enable-apc-mmap.
In APC source directory do:
/php5install/php5/bin/phpize ./configure --enable-apc --with-php-config=/php5install/php5/bin/php-config make make install
extension=apc.so include_path = ".:/php5install/php5" ;extension_dir = ./
You can guage memory usage with the apc.php script provided by the APC package.
APC is a drop-in replacement for eAccelerator, Turk MMCache, and Zend Accelerator. If you enable APC, you must disable all other opcode caching modules or get unexplained 503 errors on startup. Please note you can use APC with Zend Optimizer which is not an opcode caching module but a code optimizer.
If you do get 503 errors, please check lsws/logs/stderr.log, you may need to set “extension_dir” to where apc.so located.
When configuring PHP LSAPI extapp within LiteSpeed, you can either let LiteSpeed do all the process management, setting “max_connections” = “instances”, or let phplsapi spawn a parent process and spawn phplsapi children by setting “instances” = 1 and enter “PHP_LSAPI_CHILDREN=?” in the environment field where ? = “max_connections”. By using the PHP_LSAPI_CHILDREN method, only a single APC shared memory slice will be created and shared by all children. Otherwise, PHP will need to create an individual APC memory segment for each PHP process created.
We have found that the use of APC can artificiallly accelerate PHP's memory usage/requirement for certain scripts/operations, i.e. deserialize() large serialized packets. This is an issue within APC.
We recommend that users of APC/PHP that encounter the emalloc() errors to increase memory ceiling for external processes via LiteSpeed admin:
Either server wide: Server > Security > CGI Resource: memory limits (soft/hard) = 200M / 200M
Or on per extapp basis: VHost > External Apps > LSAPI App: memory limits (soft/hard) = 200M / 200M
Tweak, increase or decrese the values to fit your enviornment to remove emalloc() errros.