Ubuntu nginx Recompile/Repack .deb with Optional modules

There are not included in standard ubuntu deb many useful Optional Nginx modules, like:
--with-http_gzip_static_module for serve precompressed versions of static files,
--with-http_flv_module for flash streaming video or
--with-http_geoip_module for country and city variables from the IP-address and etc.

Standard way is uninstall nginx (apt-get uninstall nginx) and Building Nginx From Source with the required flags.

Other easier way recompile deb package.

Setup the dependencies to repack the package:
apt-get build-dep nginx

Get source code for the package to tmp folder:
cd /tmp && apt-get source nginx

Change compile options:
nano nginx-*/auto/options
Foe example, to enable GeoIP module need change line HTTP_GEOIP=NO to HTTP_GEOIP=YES

Compile the package:
cd /tmp/nginx-* && dpkg-buildpackage -uc -b

And install recompiled .deb file:
dpkg -i /tmp/nginx_*.deb

Аfter you upgrade to a new version nginx, this recompiled package will be overwritten. You will have to do this process again.

2 comments:

  1. Thanks! Very well done tutorial!

    ReplyDelete
  2. Just a quick tip, you can use 'sudo aptitude hold nginx' to prevent your custom build from being overwritten. You can then repackage and upgrade at your leisure.

    ReplyDelete