I have a standard version of Nginx (installed through apt-get) running my production environment (Debian Jessie).

Now I want to compile the most recent release of Nginx from source with some extra modules for testing. The executable may sit anywhere, but I want to make sure not to accidentally overwrite my production version.

What I know: I need to cd to nginx source directory and execute:

./configure --add-module=/path/to/some/module
make install

What I don't know: How to make sure that the test version doesn't install on top of the production version. Or how to install in a specific place I specify.

(I tried to read the man-pages on make but didn't come to any conclusive answer. I am rather inexperiences with compiling from source.)


You specify the installation target as an option to ./configure, not make. By default, nginx configures itself with a prefix of /usr/local/nginx, so there's no risk of overwriting the packaged version; you can specify your own path with

./configure --prefix=/your/installation/path

The default nginx setup doesn't install any files outside of its prefix, e.g. in /etc.

The installation process is documented on the nginx web site.

A general strategy to check whether a piece of software is safe to install from source is to run the installation step with the -n option (which tells Make not to actually do anything):

make -n install

This will list all the operations that would be done in a real installation. (Some build systems break with this option because later installation steps rely on the changes made by earlier ones; nginx's build works fine.)

Of course you should play around with the source build and installation steps on another system first, before touching your production system...

| improve this answer | |
  • thank's a lot. I was reading about it but wasn't sure on that point, especially if /etc files would be overwritten. – lhermann Feb 23 '17 at 17:06

You should run ./configure with the --sbin-path= option:

--sbin-path=path — sets the name of an nginx executable file. This name is used only during installation. By default the file is named prefix/sbin/nginx.

| improve this answer | |

Another idea would be to use ansible to do the configuration. Afterwards you can create new virtual machines (e.g. with vagrant) and rollout your ansible-configuration (so called playbooks).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.