Nginx with gzip static (gzip_static) support on Ubuntu

Written by
Date: 2010-04-17 10:36:30 00:00

How to compile Nginx with gzip static (gzip_static) compression support on Debian or Ubuntu

I really felt in love with Nginx I am using it and experimenting with it. As I already said in a previous post about compiling Nginx with gzip_static, one of the features I like the most is the gzip_static.

Nginx can serve gzipped content in two ways.

  • Compressing it on the fly
  • Serving previously compressed files

I like the latter a lot, but unfortunately I do not know about a Linux Distribution thats comes with that feature enabled. Even the source you download from Nginx page have this feature disabled by default.

Therefore, we need to compile it by ourselves. Compiling Nginx or any other software is something that usually scares people. It should not be that way. One reason to avoid, building software could be having to keep track of updates to new versions. As shown in the link above, this is not true for Arch Linux, and neither is for Debian or Ubuntu.

Prepare the system

This will download all dependencies needed to build the package.

apt-get build-dep nginx

Download sources

Here we will donwload the sources from Debian repo (Enable src in your sources.list).

cd /tmp/
apt-get source nginx

Enable the gzip_static option

Edit the file nginx-0.6.32/auto/options (The version of nginx for you may be different). Look for this line


And change it to:


Compiling Nginx

Enter in the nginx directory.

dpkg-buildpackage -uc -b

Install Nginx on Debian or Ubuntu

sudo dpkg -i ../nginx_0.6.32-3+lenny3_i386.deb

Your version may be different.

Now you have installed Nginx with support for gzip static, and is the current version of the Debian or Ubuntu you are running.

Keep in mind that when a new version becomes available, and you upgrade your system, the custome compiled version will be overwritten. You will have to do this process again.