RSS

Install mod_deflate in Ubunut Apache 2.2

30 Jul

By: pontikis.net

Installation

In latest Debian version (Debian 6 or Squeeze), mod_deflate is installed and enabled. If not:

a2enmod deflate
service apache2 restart
Edit website configutation file, for example:
nano /etc/apache2/sites-available/www.pontikis.net
add the following lines:
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|ico|png)$ \ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Explanation of above Apache directives:

  • Line 1: Enable gzip compression
  • Line 2: Do not compress images
  • Line 3: Do not compress already compressed files
  • Line 4: Do not compress pdf
  • Line 6-8: Some exceptions for old browsers

That’s all. Don’t forget to restart Apache.

As an alternative, you can use an .htaccess file in your webroot directory (with the same Apache directives).

Advertisements
 
Leave a comment

Posted by on July 30, 2015 in Apache2, Application Server

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: