Installing eAccelerator PHP Optimizer and Caching tool

eAccelerator is dynamic content cache and optimizer for PHP. It also encodes PHP code and increases PHP script perfomance by caching them in compiled state thus eliminating overhead of compiling PHP script every time it is accessed. It typically reduces server load and increases speed of PHP code by 1 – 10 times.

Born in December 2004, eAccelerator is a fork of Turck MMCache project.

you can download eAccelerator at http://eaccelerator.net/

Installation steps for eAccelerator on linux environment:

Requirements

apache >= 1.3, mod_php >= 4.1, autoconf, automake, libtool, m4

Copy downloaded copy of your eAccelerator version onto any location of your server, (generally it will be /usr/local/src) and continue with following steps.

OR

Download and extract the source for eAccelerator.
# cd /usr/local/src/
# wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator0.9.5.3.tar.bz2
# tar jxvf eaccelerator-0.9.5.3.tar.bz2
# cd eaccele*

Step 1) Compiling eAccelerator

execute following commands in the order.
a) export PHP_PREFIX=”/usr”
b) $PHP_PREFIX/bin/phpize
c) ./configure –enable-eaccelerator=shared –with-php-config=$PHP_PREFIX/bin/php-config
d) make

Note: You must specify the real prefix where PHP is installed in the “export” command. It may be “/usr” “/usr/local”, or something else.
Know your PHP installed location on your server, by running phpinfo() script.

On successfull compilation, there should be a “eaccelerator.so” file in the modules subdirectory of the eAccelerator source directory

Note: (Only on Errors while installing eAccelerator)
i) On some server PHP installations, phpize may not found, then error will come as ‘phpize: command not found’,

in this case you need install phpize with following command. (Command may vary depending on version of linux)

yum install php-devel

ii) If you get following error while running command ./configure
configure: error: no acceptable C compiler found in $PATH
you need to install c Compiler, run following command

yum install gcc

Step 2) Install eAccelerator

run following command

a) make install

This command will copy “eaccelerator.so” into PHP extensions directory.

Step 3) Configure eAccelerator

eAccelerator can be installed both as Zend or PHP extension.

For eaccelerator > 0.9.1, if you have /etc/php.d directory, you should copy eaccelerator.ini inside and modify default values if you need, otherwise edit your php.ini (/etc/php.ini)

To install as Zend extension:

zend_extension=”/usr/lib/php4/eaccelerator.so”
eaccelerator.shm_size=”32″
eaccelerator.cache_dir=”/tmp/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″

If you use thread safe build of PHP you must use “zend_extension_ts” instead
of “zend_extension”.

To install as PHP extension:

extension=”eaccelerator.so”
eaccelerator.shm_size=”32″
eaccelerator.cache_dir=”/tmp/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″

Note: default value for eaccelerator.shm_size is ’0′, in this case shared memory size will be taken as default value of OS. you can set it to any size you need.

Step 4) Creating Cache Directory

In this step you will create eaccelerator cache directory, that is configured in Step 3.
Default value for this /tmp/eaccelerator’

a) mkdir /tmp/eaccelerator
b) chmod 0777 /tmp/eaccelerator

Note: Generally it will be a good idea to use some other directory, otherthan ‘tmp/eaccelerator’, as this directory will be deleted on some servers while system reboot.

Step 5) restart the web server for eAccelerator to function.
(generally command will be: service httpd restart)

Step 6) To monitor eAccelerator functioning, you can perform following steps.

a) After restart web server, go into directory ‘/tmp/eaccelerator’ you can see cache pages created under some directories in that folder.

b) or you can perform phpinfo()

c) or else you can copy ‘control.php’ available in eAccelerator source folder on to your web document root.

Change user name and password in control.php to access eAccelerator control panel.

Change path of ‘eaccelerator.allowed_admin_path’ to web document root to fully monitor eAccelerator functioning in Control Panel.

Ex: if control.php is at location /var/vhost/aaayy.com/httpdocs/control.php, then

eaccelerator.allowed_admin_path = /var/vhost/aaayy.com/httpdocs

you need to restart web server, for this change.


One Response to “Installing eAccelerator PHP Optimizer and Caching tool”

  • 1 Million Says:

    Only want to say your article is astounding. The clarity in your post is simply spectacular and i can assume you are an expert on this subject. Well with your permission allow me to grab your rss feed to keep up to date with incoming post. Thanks a million and please keep up the strong work.

Leave a Reply