Apache mod_deflate module is responsible for the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network. mod_deflate is the replacement of mod_gzip which was used with older version of Apache.
The users with cPanel access only can also enable the Gzip compression. Follow our other article to enable Apache Gzip Compression in cPanel only account.
The users with root access can use the WHM panel and enable Apache mod_deflate globally for all cPanel users. Let’s follow the below steps to enable apache Gzip compression (mod_deflate) for all cPanel accounts.
Step 1 – Login to WHM Panel
You must have the root credentials of your system to get access to the WHM panel. It is required to make changes globally in a cPanel server. The default WHM is accessible on 2087 (SSL) and 2086 (non-SSL) ports.
Open a web browser and access the WHM Panel:
Login with the administrator (root) account.
Step 2 – Edit Apache Pre VirtualHost
You need to added your settings in
Pre section of Virtualhosts. So it will be loaded by the all Virtualhost in server. Let’s navigate to the below location in WHM:
Home » Service Configuration » Apache Configuration » Include Editor
Edit Pre VirtualHost Include (All versions) as per shown in below screenshot:
You may get this box empty for previously added settings.
Step 3 – Update Pre VirtualHost
Append the below configuration to the Pre VirtualHost editor and save it. Don’t overwrite any existing configuration, that are added for other purposes.
<IfModule mod_deflate.c> # Insert filter
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 no-gzip# MSIE masquerades as Netscape, but it is fine BrowserMatch bMSIE !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>
Save the changes and you will get a restart Apache button. Restart Apache service to apply all changes.
In this tutorial, you have learned to enable Gzip compression server-wide (globally) on a WHM/cPanel server. Now, use this link to verify your server gzip using one of domain configured on server.