Archive for November, 2013


The Apache module mod_deflate helps in reducing the size of the information sent to a user, by compressing things prior.  It seems to work very well.  To test if your site already has mod_deflate installed and working, you can go here:

http://developers.google.com/speed/pagespeed/insights/

0r

http://www.whatsmyip.org/http_compression/

To enable mod_deflate on your WHM / cPanel server, make sure you run EasyApache through WHM, and select to install mod_deflate.  Once done, you’ll notice that it is not active globally.  In your cPanel control panel for your domain, you should notice that under “Software / Services” an icon called “Optimize Website” is now there.  This is how you control mod_deflate on a per user basis.

If however, you wish enable it globally, so that all websites on your server can benifit from this, you need to venture back into WHM, and this time go to:

Services Configuration >> Apache Configuration >> Include Editor >> Post VirtualHost Include, and select All Versions

Now, paste the following into this file, and click Update:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule>

<IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>

That’s it, now, go back to the site I gave you at the start, load up your website, and verify that compression is now functioning.

Those who uses command line, you can achieve this my running the easy apache command line build (/scripts/easyapache), and select to include mod_deflate.  Once that is done, you can edit the “/usr/local/apache/conf/includes/post_virtualhost_2.conf” file, and paste the above code into it to achieve the same results.  Remember to restart apache once you’ve edited the file.