Integrating eAccelerator Into PHP5 And Lighttpd (Debian Lenny)

Version 1.0
Author: Falko Timme

This guide explains how to integrate eAccelerator into PHP5 and lighttpd on a Debian Lenny system. From the eAccelerator project page: "eAccelerator is a free open-source PHP accelerator, optimizer, and dynamic content cache. It 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."

This document comes without warranty of any kind! I do not issue any guarantee that this will work for you!


1 Preliminary Note

I have tested this on a Debian Lenny server with the IP address where lighttpd and PHP5 are already installed and working (e.g. like in this tutorial). I'll use lighttpd's default document root /var/www in this tutorial for demonstration purposes. Of course, you can use any other vhost as well, but you might have to adjust the path to the info.php file that I'm using in this tutorial.


2 Checking PHP5's Current State

First, before we install eAccelerator, let's find out about our PHP5 installation. To do this, we create the file info.php in our document root /var/www:

vi /var/www/info.php

Afterwards, we call that file in a browser:

As you see, we have PHP 5.2.6 installed...

... but eAccelerator isn't mentioned anywhere on the page:


3 Installing eAccelerator

Unfortunately, there's no eAccelerator package for Debian Lenny 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:

aptitude install build-essential php5-dev bzip2

Now we can download and install eAccelerator like this (make sure that you get the latest version from the eAccelerator web site):

cd /tmp
tar xvfj eaccelerator-
cd eaccelerator-
make install

eAccelerator is now installed. Now we have to tell our PHP installation that it should make use of eAccelerator. On Debian Lenny with lighttpd, the configuration files for the various PHP 5 modules are stored in the /etc/php5/cgi/conf.d directory, and this directory is referenced in the main PHP5 configuration file /etc/php5/cgi/php.ini, meaning all files in /etc/php5/cgi/conf.d are read in whenever lighttpd is started/restarted. So all we do is create the file /etc/php5/cgi/conf.d/eaccelerator.ini:

vi /etc/php5/cgi/conf.d/eaccelerator.ini

(You can read up on the various configuration settings on this page:

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

Afterwards, we restart lighttpd so that our new PHP configuration takes effect:

/etc/init.d/lighttpd restart

Afterwards, open info.php again in a browser:

You should now see eAccelerator mentioned on the page which means it has successfully been integrated and is working as expected (I've marked the eAccelerator line in the below screenshot for better visibility):


Share this page:

Suggested articles

3 Comment(s)

Add comment


By: Borderamigos

This seems to work fine on Apache2 as well.  Thanks again.


By: Michael.Terence

Hey falko, with eaccelerator they disabled some of the better performing enhancements by default as there are concerns that if a host isn't using suphp, or php-suexec other users can read from shared memory.  This is how I build it (for LiteSpeed) after compiling php5 via the web interface.

cd /usr/local/lsws/phpbuild/php-5.2.9/eaccelerator-

make clean

export PHP_PREFIX="/usr/local/lsws/lsphp5"


./configure --with-eaccelerator-shared-memory --with-eaccelerator-sessions --with-eaccelerator-content-caching --with-php-config=$PHP_PREFIX/bin/php-config


make install

I also modify the storage location and store the files in /dev/shm which offers yet another signifigant speed enhancement.  be sure to set ttl, etc or your shm will fill up... you can also use a cron to clear it out every so often.  --  this is for a box with way more ram than a small VPS... doing it on a VPS with a whole bunch of PHP scripts could cause trouble... especially if you're running apache and mysql.

By: Anonymous

These instructions were VERY helpful and worked flawlessly. I use horde and apache2 and this makes it run much faster. Adding the eaccelerator control panel is something that I sometimes find helpful.