Installing eAccelerator 0.9.5.1 on Ubuntu Feisty 7.04

In a previous article on op-code cache benchmarking, we briefly mentioned instructions on installing eAccelerator from source.

We now expand these instructions a bit to update that for installing on Ubuntu Feisty 7.04.

Download eAccelerator

First, download eAccelerator 0.9.5.1 from the project's web site. Note that 0.9.5.1 has a patch for PHP 5.2.x which Ubuntu Feisty installs by default.

Extract the archive

Extract the archive

tar xjvf eaccelerator-0.9.5.1.tar.bz2 

Configure for your PHP

Change to the directory you extracted

cd eaccelerator-0.9.5.1

Then run phpize

phpize

Then run configure

./configure --enable-eaccelerator=shared  

Build eAccelerator

Next, run make to build the binaries.

make 

Install eAccelerator

You install by running the command:

make install 

The shared object for eacclerator will be copied to where PHP can find it.

Configure eAccelerator

Starting with Feisty, Ubuntu has a new way of configuring PHP components. Instead of having all the configuration directives in a single php.ini, there is a directory called conf.d that has under it a file for each component. So, under /etc/php5/conf.d you would create a new file called eacclerator.ini and put the following in it:

Adjust your paths depending on what you want to use.

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"

Now create a simple file, say phpinfo.php and put in it the following:

<?php phpinfo() ?> 

Point your browser to the file you just created, and verify that eAccelerator is enabled.

Enable eAccelerator's control panel

You can copy the file control.php that is provided with eAccelerator to some secure location, change the account and password in it and use it to see what eAccelerator is doing. For example, it will give you a list of scripts that are used, how many times they were accessed, shared memory usage, and more.

Enjoy the speed!

Contents: 

Comments

Does it work with xdebug?

Thanks.

I see this is a zend extension. The homepage of xdebug says it has a problem with other zend extensions. Can I use both eAccelerator and xdebug?

(And it wouldn't hurt if you provided a link to eAccelerator's hoempage so we can read about it.)

Info

eAccelerator can be installed either as a Zend extension (zend_extension= as above), or as a PHP extension (extension=). So that part is not a concern.

Regarding xdebug compatibility it is better to turn off op-code caches when debugging, to be on the safe side. At least, this is what I do. A production server with heavy load will have an op-code cache on normally, but debugging would be off by default.

Just out of curiousity, I tried enabling both on my test server, and they seem to work fine, even though I left it as a zend_extension.

with eAccelerator v0.9.5.1, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
with Xdebug v2.0.0RC4, Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, by Derick Rethans

Here is a link to the eAccelerator home page. When you download the tarball that is linked above, it comes with README and a doc directory that all the info you need.

-- 2bits -- Drupal consulting

small additions to this page

Hi Khalid!

I just wanted to add something onto this wonderful instruction to make it fully complete.

In addition to following all of these above steps, your users may also need to do the following steps:


# mkdir /var/cache/eaccelerator
# chown www-data:www-data /var/cache/eaccelerator

[In the above example, choose the appropriate owner of the webserver for permissions in place of "www-data".]

I followed your instructions above, but neglected to create the cache directory, and so, until I did so, I don't think eaccelerator wasn't really activated and working.

However, once I created the cache directory, the above directions worked like a charm!

Thanks so much for this wonderful tutorial. For reference, you may also see this posting on drupal, where I also appreciate the generous help that you've given there too...

Reference on Drupal: http://drupal.org/node/173928#comment-277341

Blessings,
Albert
www.ithou.org

Worked perfectly - thank you!

Just a quick comment, worked great! - I tried the latests beta, and it failed to compile. I went ahead and used the version you linked to - worked like a charm!

Thanks,

Martin

ps: if someone goes through the trouble of creating a howto that you find useful, please don't give them a hard time about not giving you a link to a homepage that a single Google search finds easily.