eAccelerator

1. What is eAccelerator?

eA is a free open source php optimisation software. It improves the speed of php scripts by intermediate storage in compiled state. Thereby the processor load as well as the speed of scripts can be increased 1-10 fold.

2. Installation

First and foremost we have to get the newest version from… at the time of writing it was 0.9.5.2. Also it is important to note that this was written for Debian Etch.

The php development packaged need to be installed in order to install phpize

apt-get install php4-dev php5-dev
cd /usr/local/src/
wget http://bart.eaccelerator.net/source/0.9.5.2/eaccelerator-0.9.5.2.tar.bz2

Now follows the unpacking of the archive.

tar jxvf eaccelerator-0.9.5.2.tar.bz2
rm eaccelerator-0.9.5.2.tar.bz2

We now change into the directory of the unpacked archive.

cd eaccelerator-0.9.5.2

For further installation we will use a short variable.

export PHP_PREFIX="/usr"

2.1 Installation for php5

eA has to be specifically compiled for all PHP versions. Hence it is necessary to repeat these steps for php4 and php5. Also, we have to note that when upgrading the php versions eA has to be newly compiled.

$PHP_PREFIX/bin/phpize5
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config5

Now you’ll only have to copy the module into the php extension directory. It goes like this:

make install

In order to load the module we compose a configuration file:

vi /etc/php5/conf.d/eAccelerator.ini

This we fill in with the following content and save. Of course we will have to note that the variable ‘zend_extension’ is correctly put.

zend_extension="/usr/lib/php5/20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

2.2 Installation for php4

The installation of php4 is more or less the same as php5. Before you can start, you’ll have to give the following command.

make clean

As mentioned above. The installation is almost identical.

$PHP_PREFIX/bin/phpize4
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config4

Copying the module

make install

Writing the configuration file

vi /etc/php4/conf.d/eAccelerator.ini

Fill in with the following:

zend_extension="/usr/lib/php4/20050606/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

2.3 embedding in ispCP

generally eA deposits the compiled files in /tmp. IMO that is a bit insecure. For that reason we have set the directory to the /phptmp directory of the respective domain. We have to edit the following file:

/etc/ispcp/fcgi/parts/php5/php.ini
/etc/ispcp/fcgi/parts/php4/php.ini

At the end of both files we now add:

[eAccelerator]
eaccelerator.cache_dir = "{WWW_DIR}/{DMN_NAME}/phptmp"

Thus the cache directory is set to the respective root domain. An optimal solution would of course be to differentiate between subdomains and domain aliases, but that is impossible because there is only one php.ini for the main domain. Neither does insertion of php_admin_value lead to a positive result.

To finish you’ll have to regenerate the configuration. The necessary info you’ll find here:

http://www.isp-control.net/ispcp/wiki/howto_regenerate_config_files