install mod_deflate apache

How to Install mod_deflate in Ubuntu / CentOS

mod_deflate allows Apache web server to compress the response data before sending it to the client browser. This speeds up website performance and reduces data transfer costs for server. Here’s how to install mod_deflate in Ubuntu / CentOS.

 

How mod_deflate works

mod_deflate is an Apache module that enables Apache web server to compress response data before sending it to users’ browsers. It improves website performance and reduces amount of data transferred from your website. Even search engines consider low data usage on your website and improve your website rankings.

 

How to Install mod_deflate in Ubuntu / CentOS

Here are the steps to install mod_deflate in Ubuntu / CentOS.

 

1. Open Apache Configuration File

Open Apache configuration file in terminal.

You will find the Apache server configuration file located at one of the following locations, depending on your installation.

  • /etc/apache2/httpd.conf
  • /etc/apache2/apache2.conf
  • /etc/httpd/httpd.conf
  • /etc/httpd/conf/httpd.conf
$ sudo vi /etc/apache2/apache2.conf

If you have setup Apache virtual host, you can alternatively open virtual host file.

Bonus Read : How to Fix 504 Gateway Timeout Error in Apache

 

2. Install and Enable mod_deflate in Apache

Look for the following line

#LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so

and remove # at its beginning

LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so

Bonus Read : How to Check Which Apache modules are enabled

 

3. Restart Apache Web Server

Restart Apache server to apply changes.

Ubuntu/Debian

$ sudo service apache2 restart

CentOS/Redhat/Fedora

$ sudo service httpd restart

Bonus Read : How to Fix 502 Bad Gateway Error in Apache

 

4. Check if mod_deflate is working

Open terminal and run the following command to check if mod_deflate is enabled.

apachectl -t -D DUMP_MODULES | grep deflate

You should see the following output which indicates that mod_deflate is enabled.

deflate_module (shared)

 

By default, mod_deflate will compress HTML, JS and CSS files on your website.

If you want to test mod_deflate, use one of the online mod_deflate compression testing tools for websites. If you want to further optimize mod_deflate performance open its configuration file /etc/apache2/mods-enabled/deflate.conf in a text editor and update it as per your requirements.

 

5. How to Disable mod_deflate

If you want to disable mod_deflate just open the Apache configuration file mentioned in Step 2 and add # before the following line

LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so

Restart Apache web server to apply changes.

 

Hopefully, the above steps will help you install mod_deflate in Ubuntu.

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!

mm

About Ubiq

Ubiq is a powerful dashboard & reporting platform for small & medium businesses. Build dashboards, charts & reports for your business in minutes. Get insights from data quickly. Try it for free today!