Saturday, August 29, 2009

PHP Accelerator - eAccelerator

Compiling eAccelerator
phpize
./configure
make test
make
Installing eAccelerator

make install


Configuring eAccelerator

eAccelerator can be installed both as Zend or PHP extension. When you install eAccelerator as a zend_extension you need to give the full path to the eaccelerator.so library.

If you have /etc/php.d directory, you should copy eaccelerator.ini to it and modify the default values. If not, you need to edit your php.ini file (usually /etc/php.ini).

To install as Zend extension:

zend_extension="/usr/lib/php4/eaccelerator.so"
eaccelerator.shm_size="16"
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 a 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="16"
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"


Step 4. Creating cache directory ¶

One last very important step is creating the cache directory that you configured in the previous step. The default value is /tmp/eaccelerator It's easy because it's writable to everyone, but it isn't very smart because on a lot of systems this directory is cleaned on reboot. A better place would be /var/cache/eaccelerator. Create the directory and make sure it's writable for the user eAccelerator runs under (usually the user which you webserver runs as).

A safe bet is making it world writable. A safer and cleaner way would be to change the owner of the directory to the same user PHP runs as (most of the time the same user as Apache or Lighttpd) and set 0644 permissions.

The lazy way:

mkdir /tmp/eaccelerator
chmod 0777 /tmp/eaccelerator

Step 5. Checking if it works

You need to restart the webserver eAccelerator is running under. Usually this will be Apache, if using eAccelerator with Lighttpd and fastcgi, you need to kill the main PHP fastcgi server.

Verifying

There are a few ways to verify that eAccelerator is working. If the command line php binary uses the same configuration file as the php-fastcgi version and/or the mod_php version, you can check it by executing:

#php -v

When eAccelerator is loaded successfully you will see something like:

Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator

No comments:

Post a Comment

tag ur valuable ideas below