Compiling eAccelerator from source code

This is a quick guide for installing eAccelerator in a PHP environment. eAccelerator is well-known PHP memory management plug-in, it’s used to optimize execution of PHP codes.

1. Download the latest version from sourceforge.net (http://sourceforge.net/projects/eaccelerator/), and decompress it into sources code.

2. Change to the sources directory and type in the following.

export PHP_PREFIX=”/home/apache2″
$PHP_PREFIX/bin/phpize
./configure –prefix=$PHP_PREFIX –enable-eaccelerator=shared –with-php-config=$PHP_PREFIX/bin/php-config

This would set up the environment and install eAccelerator in $PHP_PREFIX.
3. Now run “make && make install” to compile the source code and install the DSO.
4. To activate eAccelerator you need to edit your PHP config file which resides in /home/apache2/lib/php.ini from my side, and you can use the following command to check where it is on your side:
[/home/apache2]# bin/php -i | grep php.ini
Configuration File (php.ini) Path => /home/apache2/lib
Loaded Configuration File => /home/apache2/lib/php.ini

Then, add the following lines at the end:
[eaccelerator] zend_extension=”/home/apache2/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so”
eaccelerator.shm_size=”16″
eaccelerator.cache_dir=”/tmp/eaccelerator”
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″

The README in the source directory gives a very good explanation of those parameters. The only one you should probably alter is the shm.size because 16MB of shared memory might be not enough.
5. Last step is to create the directory where eAccelerator stores the cached scripts which don’t fit into the shared memory. According to my settings:
mkdir /tmp/eaccelerator && chmod 0755 /tmp/eaccelerator

Now, you need to restart the web server to make it take effect.

Share Button

Leave a comment

Your email address will not be published. Required fields are marked *