The following post discuss how to install mod_deflate on cpanel server. Before going through here are few advantages of having mod_deflates installed in cpanel server. 🙂
- Compresses the content once and saves the result using less CPU load on server.
- It uses level 9 compression because it’s only run once per file.
- It’s compatible with Apache 1.x, 2.x & 2.2.x versions.
- In general, all you need to do is enable the module and it works; no core hacking/modifying .htaccess just adding a little configuration via WHM will do all the tricks by enabling it on all the sites.
- Cpanel do provide an addition option to optimize the size under the cpanel user panels. Sceen-shot is below :
1 – > Login in to whm as root ” Software -> EasyApache (Apache updates)” and select the mod_deflate modules under the apache module list page (make sure you have done a httpd.conf before proceeding further) and recompile the apache.
2 -> Once built, you need to tell it to do something. You’ll see a new icon on your sites cPanel now, called “Optimize Site”. You can enable it on a per site basis.
3 -> To enable it on all the sites running in the server, you need to edit the :
- Apache Configuration
- Include Editor
- Select All Versions of Post VirtualHost Include
- Paste the following below
AddOutputFilterByType DEFLATE text/html text/plain text/xml
# 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 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 \
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
This will automatically restart the apache server after saving. After restart try testing the site in the following url :