blog.up-link.ro android bsd linux unix & open-source world

7Aug/102

How To Install and Integrate eAccelerator into PHP5

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed or subscribe via E-mail for updates on this topic.

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:

CentOS/Fedora/RHEL

yum install php-devel

Debian/Ubuntu

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.

CentOS/Fedora/RHEL

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.

vi /etc/php.d/eaccelerator.ini

Debian/Ubuntu

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.

vi /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:

CentOS/RHEL/Fedora

service httpd restart

Debian/Ubuntu

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 :

eAccelerator PHP Cache and Optimizer

NOTE:
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

Print This Post Print This Post
Comments (2) Trackbacks (0)
  1. Hi, I have tested “APC”, “eAccelerator” & “XCache”… XCache was faster then the others.

    PS: I combine php5-fpm + XCache with nginx

  2. if your are using virtual host and you want to disable eaccelerator in some site use this setting in your vhost.conf file
    php_admin_value[eaccelerator.enable] = Off
    php_admin_value[eaccelerator.optimizer] = Off


Leave a comment


*

No trackbacks yet.