opcode caching with eaccelerator — on shared hosts

Opcode caching helps!

From the eaccelerator home
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 one’s for Dreamhost accounts. It will work for some other shared hosts as well. In case you need it setup on your server let us know through the Contact Form

  • Make sure you have your own custom php-fcgi (notice the ‘f’ it cost me two hours to figure that out) compiled and running the site where you want to enable eaccelerator. Detailed instructions rolling your own custom php are available elsewhere on this site.
  • get eaccelerator latest version and compile it
  • add the settings to the relevant php.ini
  • all set roll

For eaccelerator
The exports are for making sure you work with the right php. Again you will need autoconf, automake and php-devel(phpize) for the compile to work.

wget http://bart.eaccelerator.net/source/
export TMPDIR=$HOME/executable/tmp
export PATH=$HOME/executable/bin:$PATH
export LD_LIBRARY_PATH=$HOME/executable/lib:/usr/local/lib:$LD_LIBRARY_PATH
export CPATH=$HOME/executable/include:/usr/local/include:$CPATH
export LIBRARY_PATH=$HOME/executable/lib:/usr/local/lib:$LIBRARY_PATH
tar -jxf eaccelerator-
cd eaccelerator-
./configure --prefix=$HOME/executable/
make install

For the php.ini
These lines are for loading and configuring ea in the custom php you use. So add them to the php.ini that pops up on your phpinfo page.

eaccelerator.shm_size = "20"
eaccelerator.cache_dir = "/home/user/tmp/eaccelerator"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.debug = 1
eaccelerator.log_file = "/home/user/log/httpd/eaccelerator_log"
eaccelerator.name_space = ""
eaccelerator.check_mtime = "1"
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"
eaccelerator.allowed_admin_path = ""

This is what your .htaccess should look like (assuming you got the precompiled php bit right)

well if you got your custom php working right then this is not going to change any

[koolaid]$ cat .htaccess
AddHandler phpFive .php
Action phpFive /cgi-bin/php.cgi

And here’s your php with eaccelerator in there

[koolaid]$ php -v
PHP 5.2.3 (cli) (built: May  8 2009 09:08:36)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
    with the ionCube PHP Loader v3.1.32, Copyright (c) 2002-2007, by ionCube Ltd., and
    with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.3.0, Copyright (c) 1998-2007, by Zend Technologies

Make sure that eaccelerator is also enabled in php by checking a phpinfo page like so:
phpinfo snip

Log should show hits also phpinfo page will show you the number of cached scripts.

Might want to benchmark it using something like phpspeed before and after the eaccelerator is plugged in….

Well this should ideally speed things up by around 60% so you’ll know when that happens 😀


4 thoughts on “opcode caching with eaccelerator — on shared hosts”

  1. You have to get this! It’s like putting it in TURBO Mode!

    Imtiaz does a very professional and fast install making it quick and easy.

    So, if you want to ignite the afterburners this is a must!
    You can’t go wrong with Imtiaz at the controls.

    Highly Recommended.

  2. i want you to make a long travel this time, i am adding some additional diesel if you work out the two other solutions you told me for tonight 🙂
    Hey guys! i know he will do it, Imtiaz has never failed what he started…

  3. The site was very slow, we were thinking to re-develop the kernel of the site but i saw this post about eaccelerator and talked with Imtiaz.
    The site is a ferrari now with respect to its initial conditions. Imtiaz is THE magician of the servers, whatever the problem is, i always ask him, he solves everything and most of all…. he is funny and nice. If you have any problem, just ask him and consider it solved. I am affectionate to him now, can’t live without him 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *