I really felt in love with Nginx I am using it and experimenting with it. As I already said in a previouse 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.

  1. Compressing it on the fly
  2. 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.

  1. Prepare the system

  2. This will download all dependencies needed to build the package.

    apt-get build-dep nginx

  3. Download sources

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

    cd /tmp/

    apt-get source nginx

  5. Enable the gzip_static option

  6. Edit the file nginx-0.6.32/auto/options (The version of nginx for you may be different). Look for this line
    HTTP_GZIP_STATIC=NO
    
    And change it to:
    HTTP_GZIP_STATIC=YES
    
  7. Compiling Nginx

  8. Enter in the nginx directory.

    dpkg-buildpackage -uc -b

  9. Install Nginx on Debian or Ubuntu

  10. 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.