On the last blog I wrote for was an article which described who to install eAccelerator on a Ubuntu server. As this blog entry had a lot of visits I decided to put it on this blog again:
PHP is not the fastest scripting language, that truly a fact. Except from optimizing the scripts there a few possibilities to speed everything up. One is to install a byte code optimizer and cache on your server. They cache the byte code created by the PHP parser and try to optimise it. So every time some one requests for a page on your server the script does not have to be parsed again. This brings a speedup of 120 – 250% depending on you script. There are several byte code caching program available, the one I like most is eAccelerator. Sadly eAccelerator is not available through the Ubuntu repositories so you have install them yourself. Here is a short description how to archive this!
Everything is done from the terminal as a root user.
- Prepare you system for compiling a PHP extension:
apt-get install build-essential php5-dev
- Choosing a folder for build process. I used “/usr/local/src/”
- Getting the sources from the eAccelerator site:
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.zip
- Extract and delete the archive
unzip eaccelerator-0.9.5.3.zip && rm eaccelerator-0.9.5.3.zip
- Enter the folder
cd eaccelerator-0.9.5.3
- Prepare as a new PHP extension and compilation
phpize ./configure --enable-eaccelerator=shared
- Compile and install
make make install
The install process prints out a folder where eAccelerator has been installed. Remember or copy it, you will need this later.
- Enabling eAcceletor: Editing your “php.ini” or create a new ini file in you conf.d directory of PHP. (You can find them here: “/etc/php5/”.) Insert the following:
zend_extension = "/usr/lib/php5/20060613+lfs/eaccelerator.so" eaccelerator.shm_size = "0" 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 = "7" eaccelerator.allowed_admin_path = "/var/www/eaccelerator"
In the first line enter the path printed out during the install. In the last line you could enter a directory for the eAccelerator admin tool, if you want to use it.
- Create the cache directory:
mkdir /var/cache/eaccelerator chown www-data.www-data /var/cache/eaccelerator
- Restart you Apache!
/etc/init.d/apache2 restart
There are a lot of setting in the ini file. The whole list and the description of them could be found here: Ini-settings.
To check if everything is working open up a page on the server that contains the “phpinfo();” command. There should be some thing like this:

eAccelerator
Enjoy the speed!
Comments