The mod_deflate is a very useful apache module which increase the loading speed of your websites. You can enable this module simply by rebuilding your apache by using easyapache if you have server with control panel WHM/cPanel.
Method I (Server with cPanel)
Enable mod_deflate via easyapache.
You can rebuild your apache by running the command below.
# /scripts/easyapache
Before executing easyapache make sure that you have taken a backup of both Apache and Php conf file and also notice the current version of your apache and php. That will be helpful in your easyapache steps. Command to find the php configuration file.
# php --ini
Command to find Apache and php version.
# httpd -v (Apache)
# php -v (PHP)
Do execute the easyapache carefully.
Method II (Server without cPanel)
Enable mod_deflate by editing apache conf(httpd.conf) file.
Add the following lines to configure mod_deflate in your apache configuration file.
<IfModule mod_deflate.c> # compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE image/x-icon </IfModule>
If you want to compress only a few types, you can add the following line to the apache conf.
AddOutputFilterByType DEFLATE text/html text/plain text/xml
Restart the apache service to coplete the process,
# /etc/init.d/httpd restart
Or
# service httpd restart
Command to check the modules in httpd
# httpd -M
Command to check the httpd conf syntax.
# httpd -t
That’s it
Similar topics
How to disable ‘Directory listing’ in Apache web server?
How to change the apache port via command line in cpanel
Hi ,
is there any way to turn on “mod_deflate” from cpanel for clients?
i guess my hosting provider don’t want to install this feature for some unknown reason!!!
my host Apache ver. is 2.2
please help, thanks.
Reza,
It’s an Apache module and need to rebuild the Apache with this module.