Technology Blog

Install eAccelerator to Optimize PHP performance

0

Server load increase? looking for ways to optimize your php performance? if you have php optimization problem, you should try PHP eAccelerator. PHP eAccelerator is a free open source PHP accelerator, optimizer and dynamic content cache module that specially build to optimize php performance. According to php eaccelerator official site, php accelerator able to speed up the php code by 1-10 times and reduce server load.

How PHP eAccelerator able to speed up php code and reduce server load?

PHP eAccelerator works this way, whenever there is request to a file, PHP eAccelerator will parse the php file and cache them in their compiled state in the shared memory. So when the next request come, php eAccelerator will serve the request using the cache and it completely eliminated the compile state, so it will speed up php execution. (*Files that can’t fit in shared memory are cached on disk only.)

Interested with PHP eAccelerator? How to install PHP eAccelerator?


First download PHP eAccelerator source distribution from here or you may download their binary distribution. Extract it and follow the steps below:-

  • enter phpize in the extracted directory. if this doesn’t work, you may want to enter full path ex: /usr/local/php/bin/phpize
    * You need to have php 5 or php 5, autoconf, automake, libtool and m4 installed before execute this command
  • Once phpize is done, enter

    $ ./configure
    $ make
    $ make install

  • Once everything done, it will show you the path to the compiled extension, copy down that path. Then open your php.ini and add the following code under the extension section.

    zend_extension=”/your/compiled/extension/path/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″

    Then replace the zen_extension path with the path you take down just now.

  • Once this is done, create a /tmp/eaccelerator directory. and set permission to all like below:-

    $ mkdir /tmp/eaccelerator
    $ chmod 0777 /tmp/eaccelerator

  • Done! Restart your apache and do a phpinfo. you will notice there will have a eAccelerator section. If you didnt see the eAccelerator section, eAccelerator is not loaded.
    You can refer to documentation at the PHP eAccelerator official site

Visit PHP eAccelerator Official Site for more information.