DirectAdmin: Web control panel

Caching systems

by ross at 07:23:18 on October 28, 2011

This is short version of original article adjusted to DirectAdmin environment. You should read it first.


eAccelerator increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated.

# cd /usr/ports/www/eaccelerator
# make install clean

# mkdir /var/tmp/eaccelerator
# chown apache /var/tmp/eaccelerator
# chmod 700 /var/tmp/eaccelerator

Edit /usr/local/lib/php.ini, add before [Zend] if you have it or just after commented out extension= lines:

eaccelerator.debug = 0
eaccelerator.cache_dir = /var/tmp/eaccelerator

APC (incompatible with Zend Optimizer)

APC is the Alternative PHP Cache. It was conceived of to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.

# cd /usr/ports/www/pecl-APC
# make install clean

Edit /usr/local/lib/php.ini, add after commented out extension= lines:



First, install and start the memcached daemon just like in the original article. Then install the extensions:

Edit /usr/ports/databases/pecl-memcache/Makefile, comment out USE_PHP= line (add # to the beginning).

# cd /usr/ports/databases/pecl-memcache
# make
There will be errors. It's OK.
# cd work/memcache-3.0.6
# phpize
# ./configure
# cd ../..
# make install clean
# cd /usr/local/lib/php/20090626
# ls -l ../extensions/
total 2
drwxr-xr-x  2 root  wheel  512 Aug 28 15:25 no-debug-non-zts-20090626
# ln -s ../extensions/no-debug-non-zts-20090626/

If your PHP is thread-safe (i.e. built for Apache's worker MPM) then the directory will probably be no-debug-zts-20090626.

Edit /usr/local/lib/php.ini, add after eAccelerator or APC lines:

Repeat procedure for databases/pecl-memcached — but only if Zend Optimizer is not installed (it's not compatible, you will get segfaults with it). Don't forget to edit its Makefile the same way.