Articles & Code Snippets

Enable GZIP Compression in WHM

How to add GZIP compression server-wide in cPanel WHM EasyApache3 or EasyApache4

In cPanel WHM EasyApache3 or EasyApache4, you can add GZIP compression server-wide, including new accounts, by adding the following to Service Configuration → Apache Configuration → Include Editor → Pre Virtualhost Include → All Versions:

# Enable GZIP Compression.
<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
    <IfModule mod_setenvif.c>
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        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 mod_headers.c>
        Header append Vary User-Agent env=!dont-vary