How to Enable Apache Gzip Compression (mod_deflate) Globally in WHM/cPanel

Login to cpanel then WHM
Select Service Configuration — Apache Configuration — Include Editorand Then edit Pre VirtualHost Include – All versions

Add the following code then hit update

<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 mod_headers.c>
		# Make sure proxies don’t deliver the wrong content
		Header append Vary User-Agent env=!dont-vary

Code source:

Restart Apache

So now Apache Gzip Compression (mod_deflate) is enabled globally on your WHM/cPanel


How to enable Gzip compression using the .htaccess file

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *