Configure and Enable GZIP Compression with mod_deflate in cPanel server

One way to improve the serving speed of web pages is to enable GZIP compression to compress the size of web pages been transferred. Compression, which results in reduced web page size, also has added benefit of saving bandwidth. With all the benefits of GZIP compression, it effectively offsets the performance penalty on server load caused by the compression activity.

Note that Apache 1.3 uses mod_gzip, while Apache 2.x (2.0 and 2.2) uses mod_deflate. The guide focuses on Apache 2.x with mod_deflate to turn on GZIP support.

Step 1# Compiling Apache with mod_deflate Module

Note: The step can be skipped if mod_deflate has already been compiled into Apache. To verify, run httpd -t -D DUMP_MODULES command on the server, and look for deflate_module (static).

Login to cPanel WHM (WebHost Manager), and run EasyApache (Apache Update) under Software section. Select radio button of Previously Saved Config, and click on Start customizing based on profile button.

Do whatever changes you prefer during each steps of wizard, else just click Next Step buttons, and finally click Exhaustive Options List button. Select and tick the check box for Deflate under Apache Built-in Modules. Click on Save and Build to start re-building Apache.

You can install mod_deflate using the cPanel script /scripts/easyapache through SSH as root.

Step 2# Add the following codes in the .htaccess file of the domain

 <IfModule mod_deflate.c>
     <IfModule mod_setenvif.c>
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
       BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    </IfModule>
   <IfModule mod_headers.c>
       Header append Vary User-Agent env=!dont-vary
   </IfModule>
  <IfModule mod_filter.c>
     AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
  </IfModule>
</IfModule>

Step 3# Verify it using the following commands

$ curl -A 'Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20100101 Firefox/6.0.2' -H 'Accept-Encoding: gzip, deflate' http://www.yourdomain.com --output yourdomain_output

$ file yourdomain_output

You can also check it using the following online checker:

http://www.gidnetwork.com/tools/gzip-test.php

Comments

  1. Help full article....keep it up..

    ReplyDelete
    Replies
    1. Hallo Avinash,
      Je Artikel lijkt me echt interessant en heb idem hetzelfde probleem.
      Ik weet waar ik de modules kan inschakelen etc maar ik snap niet wat je bedoeld met httpd-t-D DUMP_MODULES of waar ik dit kan uitvoeren om te controleren?
      Vriendelijke groeten

      Delete
    2. Configure And Enable Gzip Compression With Mod_Deflate In Cpanel Server >>>>> Download Now

      >>>>> Download Full

      Configure And Enable Gzip Compression With Mod_Deflate In Cpanel Server >>>>> Download LINK

      >>>>> Download Now

      Configure And Enable Gzip Compression With Mod_Deflate In Cpanel Server >>>>> Download Full

      >>>>> Download LINK Kk

      Delete
  2. Thanks for sharing such a good information...

    BlueHost Hosting Reviews

    ReplyDelete

Post a Comment

Popular posts from this blog

SVN: File remains in conflict

HowTo: Enable extended logging for exim

Error: could not open mime types config file