GoWilkes

Well-Known Member
Sep 26, 2006
703
34
178
cPanel Access Level
Root Administrator
I'm setting up a new WHM/cPanel server. Using EasyApache, I've updated Apache to version 2.2.24, and under "Exhaustive Options", I have "Deflate" checked. But the output does not appear to be compressed, and when I look at httpd.conf, I don't find "deflate" referenced anywhere in the file.

I looked through my old server's httpd.conf file, too (which has Apache 2.0.64), and also didn't find any reference to "deflate". But, it's definitely gzip compressed, according to several online tools. So even though I found a few tutorials online that said to uncomment specific lines in the httpd.conf file, that doesn't seem to be the same thing that I had before, since those lines never existed yet the server was still compressing.

Just to be clear, I'm wanting to compress everything to use the least amount of bandwidth possible, even if it does create more of a load on the CPU. I have plenty of CPU to spare, but not bandwidth.

Further, I did find references to adding the following to the top of all pages:

<?php
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
ob_start("ob_gzhandler");
else ob_start();
?>

But of course, this has the limitations that:

1. It only works on PHP pages;

2. It requires an update to hundreds, maybe thousands of pages; and

3. It relies on the account owners to continue adding it themselves, instead of it being automatically loaded.

Any advice on how to enable Gzip or mod_deflate correctly would be very appreciated! TIA,

Jason
 

ES - George

Well-Known Member
PartnerNOC
Jun 12, 2011
178
25
78
UK
cPanel Access Level
DataCenter Provider
Twitter
Hello :)

Once mod_deflate has been loaded via EasyApache, it must be activated via the cPanel account that you wish to enable compression for (the Optimize Website icon). I have attached a screenshot which shows this.
 

Attachments

GoWilkes

Well-Known Member
Sep 26, 2006
703
34
178
cPanel Access Level
Root Administrator
Thanks, George! I think I knew that once upon a time, but forgot. It's kinda unfortunate that there's not a way to simply do it for all accounts; I can't think of any reason that I wouldn't want an account to be compressed, and I just spent almost 3 hours enabling it manually for 108 different accounts!
 

GoWilkes

Well-Known Member
Sep 26, 2006
703
34
178
cPanel Access Level
Root Administrator
Update:

For others reading this, I just found an article that said you CAN turn on "Optimize Website" globally in WHM. I haven't tried this, to use at your own risk.

Step 1. Go to Services Configuration >> Apache Configuration >> Include Editor >> Post VirtualHost Include, and select All Versions.

Step 2: Paste this in to the corresponding file:

<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 \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>
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello :)

Feel free to open a feature request if you would like to see an option in WHM to enable compression on multiple accounts:

Submit A Feature Request

Thank you.