Tech Magazine

How to Accelerate PHP Enabled Website

Posted on the 20 October 2010 by Hostingnuggets @hostingnuggets

Do you want to keep the load down on your web server and at the same time accelerate the rendering of your PHP web pages? Then eAccelerator is exactly the PHP module you are looking for! eAccelerator is a very simple and small module which you add to your PHP installation and that will increase the performance of your PHP code by caching it in compiled state either in memory or on your hard disk. Even better news, eAccelerator is open source so that it is free for anyone to use. I personally use it all the time and I must say that you really see a difference in the time used for PHP code compilation and execution.
Using this accelerating PHP module I can get up to 50% reduced loading time for a web page and the documentation mentions that it can reduce even more the loading time of your PHP pages. Quite useful if you are running a busy website or simply want a faster website which has quite some PHP code behind it. Furthermore it's easy to configure and just has a bunch of around 10 parameters to configure, whereas most of them can be left as default. For performance reasons, I would suggest you install it from source; there are very good installation instructions available on their website. Basically it's just about running the following commands once the package is decompressed:
phpize ./configuremakemake install
Then you enable the module via PHP's php.ini config file by adding the following parameter:
extension="eaccelerator.so"
as well as the little configuration parameters there is:
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"
Last recommendation: create a dedicated cache directory (eaccelerator.cache_dir) somewhere else than /tmp because anybody who has access to that machine can read the content of /tmp and give it read-write permission just for your web server's user (very often www-data or nobody). Enjoy your accelerated PHP website!

Back to Featured Articles on Logo Paperblog

Magazine