CentOS 5 is packaged with Apache 2 which is not compatible with mod_gzip. The module mod_deflate is the Apache 2 equivalent.
Installing mod_deflate on CentOS 5 is a fairly simple process. The module is included in CentOS 5 and just need to be configured.
The only changes required are to the Apache configuration file /etc/httpd/conf/httpd.conf. I recommend that you take a backup before you make any changes.
Here are the steps that I took:
1. Check that the deflate module is loaded.
In my configuration file this was already done with this line:
LoadModule deflate_module modules/mod_deflate.so
If this is not there then I suspect all that is required is to add this line. However if you need to do this I recommend that you check the module /etc/httpd/modules/mod_deflate.so is installed.
2. Configure the deflate module
All that was required was to add the following lines to the Apache configuration file.
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\. no-gzip
BrowserMatch \bMSIE\s7 !no-gzip !gzip-only-text/html
BrowserMatch \bOpera !no-gzip
Header append Vary User-Agent
Update 26/08/2008: Originally I only had the first line of the above configuration. However it turns out that there are issues with Internet Explorer 6 and HTTP compression.
I added this after
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
but you should be able to add it anywhere in the main section.
3. Restart Apache
service httpd restart
4. Test it’s working
The easiest way to check that it is working is with the YSlow plugin for Firebug. Firebug is a Firefox plugin that will give you lots of useful information.
To test just load a page in your browser, go to the Firebug/YSlow plug and select the “Performance” option. This will give you a performance grade. You should hopefully see an “A” for “4. Gzip components”. If not do a Ctrl-F5 to ensure that you’re not viewing cached content.
If this still does not report an “A” for “4. Gzip components”. then it is possible that your page has other content types that need to be added for YSlow to be happy.
This is only a quick overview of the steps I took, and by no means comprehensive A more detailed tutorial is available here: http://www.howtoforge.com/apache2_mod_deflate