eAccelerator is an open source PHP accelerator, optimizer, and dynamic content cache which provides a bytecode cache. eAccelerator increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.
1. Install prerequisites
There is no eAccelerator package in the official repositories, therefore we must compile and install it from the sources. Before we can do this, we need to install some prerequisites.
Install php development package to get phpize:
yum install php-devel
apt-get install php5-dev
Now we can proced with the next step.
2. Install eAccelerator
Now we have to download and install eAccelerator (you should always get the latest version from the eAccelerator website):
cd /tmp wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2 tar xfj eaccelerator-0.9.5.3.tar.bz2 cd eaccelerator-0.9.5.3 phpize ./configure make make install
eAccelerator is now installed.
3. Enable eAccelerator in PHP
Now we have to tell our PHP installation that it should use eAccelerator.
The configuration files for the PHP 5 modules are stored in the /etc/php.d directory. So we create the file /etc/php.d/eaccelerator.ini.
The configuration files for the PHP 5 modules are stored in the /etc/php5/conf.d directory. So we create the file /etc/php5/conf.d/eaccelerator.ini.
Add the following lines to /etc/php.d/eaccelerator.ini or /etc/php5/conf.d/eaccelerator.ini :
extension="eaccelerator.so" eaccelerator.shm_size="16" eaccelerator.cache_dir="/var/cache/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"
As you see, we are using the disk cache directory /var/cache/eaccelerator which we must create now and make it world-writable:
mkdir -p /var/cache/eaccelerator chmod 0777 /var/cache/eaccelerator
We restart Apache so that our new PHP configuration takes effect:
service httpd restart
service apache2 restart
4. Test if eAccelerator is enabled in PHP
Open info.php in browser. You should now see eAccelerator mentioned on the page which means it has successfully been integrated and is working as expected :
You can disable eAccelerator per virtual host by adding the following lines to vhost configuration:
php_admin_value eaccelerator.enable 0
php_admin_value eaccelerator.optimizer 0