How to configure gzip compression in cPanel server via mod_deflate and Apache

This small tutorial will help you to enable mod_deflate gzip compression in your cPanel server. You may need to do the following procedure.

1) Do easyapache and enable mod_deflate in your apache. After finishing it create a file named  /usr/local/apache/conf/deflate.conf with the following content


<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
DeflateCompressionLevel 9
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE image/svg+xml

2) Include the file  /usr/local/apache/conf/deflate.conf   inside   /usr/local/apache/conf/includes/pre_main_global.conf   , as follows

Include “/usr/local/apache/conf/deflate.conf”

3) Now restart  your apache as follows,

/scripts/restartsrv httpd

4) Test the compressed speed of your website from  http://www.whatsmyip.org/http_compression/