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.

Advertisement

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:

https://11.22.33.44:2087

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:

cpanel-apache-pre-virtualhost

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[678] 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>

The above configuration has been taken from Here. So read this article carefully before implementing it.

Save the changes and you will get a restart Apache button. Restart Apache service to apply all changes.

Conclusion

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.

Share.

32 Comments

  1. James Mworia on

    Thanks for the information.I had been looking for way to compress content on my website and this by far is the easiest and best.

  2. I cannot thank you enough. It actually works beautifully. You have also explained it in such a easy implementable way. Setting it up was a breeze. I looked for this information earlier also, but couldn’t find anywhere on the net. But I guess I got lucky this time. Just implementing this increase speed up by 10%.

  3. Thank you for this! We have rolled out this globally with our servers! With Deflate sites looks to be working better and faster.

    Thanks!

Exit mobile version