5 Must Have Apache Modules and PHP Optimizers

Posted: April 14, 2010 in PHP

The Apache web server and the PHP scripting language are present on over 70% of all servers online. Without them it would be impossible to run literally millions of scripts and server web pages to the visitors of a site. These are 2 tools that are truly essential to the operation of a world wide web server.

Of course, there are alternatives for both (ASP, Javascript for PHP and Lighttpd or Nginx for Apache, for example), but none of them have gained such a widespread use in the web hosting and serving sector. Plus, as I said above, there are a lot of scripts written in PHP, and without it on a server, it would be impossible to run them. Many Small Business Web Hosting Services are Offering PHP, CGI, Ruby (RoR), Perl etc.,

As with any other software, users can modify, improve and optimize Apache and PHP to fit their needs. For this, there are a lot of modules, extensions and optimizers, and below we’ll take a look at the most important of them, which are a must have for every server running PHP and Apache.

mod_deflate: This Apache module will help you save bandwidth and decrease your site’s page load time (especially useful for all those visitors that don’t have 10Mbit Internet connections). It works by compressing the output from the server before sending it to the user. You can configure which browsers it should ignore (not all of them work with this module) and the compression level and details. The drawback is that the server will have a higher CPU load and possibly a slightly increased latency, due to it having to process and compress all the files and data before sending them.

mod_gzip: This Apache module works in the same manner as mod_deflate, the difference being that it uses gzip to compress all data, which results in even smaller (20-30%) output size than mod_deflate. It is best to use mod_gzip together with mod_deflate, because a lot of versions of the most commonly used browsers (IE, Firefox, Safari and others) don’t support mod_gzip and almost always have a few bugs. Additionally, mod_gzip uses even more CPU time than mod_deflate, so you should only use it if you have good processing power (4 and more cores).

mod_bw: Another Apache module that can help you save bandwidth (both in the sense of monthly volume and Mbits per second). It works as an output filter in the Apache filters chain. All the data that is downloaded by users goes through it, and if you set a bandwidth limit (for example, allow only 20Mbit/s output of the total 100Mbit/s), the module will start splitting the data into smaller parts and increase the send delay between each part, which will result in a slower download speed for the user, which in turn will save bandwidth. It can be very useful when, for example, you have a file hosting site and a popular blog on the same server. If the blog gets “Slashdotted” (i.e. gets to the front page of a social network like Slashdot or Digg) and you don’t want it to become inaccessible because a lot of users are downloading files at full speed from the file hosting site, you can limit the latter’s bandwidth, which will result in an accessible blog with a lot of traffic and a functional file hosting site (albeit with slower download speeds).

Zend Optimizer: This is a free runtime application that enables the server it’s installed on to run PHP scripts encoded with Zend Guard and, more importantly, accelerate the opcode for better performance. There are a lot of scripts which you may need to use that are encoded with Zend Guard, and having Zend Optimizer pre-installed and configured will help you avoid any problems that might arise when you first try to run one.

eAccelerator: This is a very useful application that is a must have for any server that experiences constant medium to heavy loads. It is a PHP accelerator and optimizer that increases the performance of PHP scripts significantly (typically 3-10 times faster) and reduces server loads (by the same amount) by caching all of them in their compiled state, so that any time they’re re-run, they don’t have to be compiled again. This of course, reduces the processor time and RAM memory used by a high degree, and because a typical modern site is 80% made of PHP scripts, it is a very good tool to have for anyone.

So, now you know a few modules and applications that will increase the performance and stability of any server running Apache and PHP, while reducing bandwidth usage and costs. Try them out!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s