How to compile Nginx from sources

9 Dec 2017

Let's make custom .deb package of Nginx Web Server.

First step is adding official nginx apt repository -

Next, install dpkg-dev package:

apt-get install dpkg-dev

Download nginx sources:

apt-get source nginx

Install dependencies:

apt-get build-dep nginx

Now, let's open file nginx-*/debian/rules and edit build configuration.

For example, we can specify which nginx modules do not include in the assembly, or vice versa. My list looks like this:


Now, go to folder

cd nginx-*

and execute command for building our package:

dpkg-buildpackage -b

As a result, in parent folder you will find nginx-*.deb files: debug and regular version.

Now you can install the package, just execute command:

dpkg -i <your-package-name>.deb