A common optimization that can be done for php to improve performance is to install Alternative PHP Cache (APC).
What it does, is it caches php files in memory in their parsed and compiled state.
This removes the need for re-reading, parsing, and compiling for each request, thus greatly lowering your system load.
The cost of using this mosulde is increased memory usage, since that's where the cache lives.

Note - This won't work with suPhp, since each call to php is with a seperate binary call, and doesn't share the same memory. CLI is always running in memory, hence can shared the same memory, which is why it works.

1) To install it with the default CLI version of php, use the following:
PHP Code:
PHP Code: 
cd /usr/local/directadmin/custombuild 
wget http
://pecl.php.net/get/APC-3.1.9.tgz 
tar xvzf APC-3.1.9.tgz 
cd APC
-3.1.9 
/usr/local/bin/phpize 
./configure --with-php-config=/usr/local/bin/php-config 
make 
make install 


2) Then, we needed to edit the php.ini to add the code:

PHP Code:
PHP Code: 
extension=apc.so 
apc
.enabled=
apc
.shm_size=128M 
apc
.ttl=7200 
apc
.user_ttl=7200 
apc
.enable_cli=


3) as well as change the php.ini line from:
PHP Code:
PHP Code: 
extension_dir "./" 
to be



PHP Code:
PHP Code: 
extension_dir "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/" 



but, this may vary per system. The "make install" command will tell you where the apc.so was installed to (Installing shared extensions.

Note that this is a 3rd party module, and would be beyond our technical support for any issues that arise.



Note: It's been observed that with APC enabled, php may not install on the "make install" step. The error it produces is as follows:

PHP Code:
PHP Code: 
Fatal error: Class 'PEAR' not found in phar://install-pear-nozlib.phar/index.php on line 24 
make[1]: *** [install-pear-installerError 255 
make
: *** [install-pearError 2 


After removing the APC options from the php.ini, it installed. The APC could be re-enabled.
Albert.Nawaro Reviewed by Albert.Nawaro on . Installing Alternative PHP Cache (APC) on Directadmin A common optimization that can be done for php to improve performance is to install Alternative PHP Cache (APC). What it does, is it caches php files in memory in their parsed and compiled state. This removes the need for re-reading, parsing, and compiling for each request, thus greatly lowering your system load. The cost of using this mosulde is increased memory usage, since that's where the cache lives. Note - This won't work with suPhp, since each call to php is with a seperate binary Rating: 5