What happens to installed NGINX version if I compile another version from source ?

June 7, 2016 343 views
LEMP Nginx Linux Basics

I have create a LEMP stack and NGINX 1.4.6 is installed. I was wondering what will happen if I compile a different version of NGINX (1.10 for example) and add my modules of choice.

Will it 1.10 overwrite version 1.4.6 and is this just like 'updating' the previous version ? Or is it a necessary to first remove the previous version and then compile the newer version ? Basically I'm asking this because I also wan to know what happens to the virtual hosts which I might have configured ... (and ofcourse config file)

2 Answers

If you're worrying about your filesystem, you should back up your system prior to making the configuration change.

That being said, I'm pretty sure that by default Nginx installs its files to a different location than stock packages (prefix /usr/local/)

  • Thank you for your answer ... I think it's the right idea also to first make a snapshot / backup ... I was wondering if a re installation of the same software will overwrite the existing files or that I will end up with two installations of the software on the server actually ...


When compiling from source, as in, downloading the source code from NGINX and running actual build commands from the CLI, you're able to specify the exact location of where NGINX stores files as well as what directories NGINX will use for said storage. As long as you specify different locations, the previous versions' files and directories should remain unmodified.

You could technically run ten versions of NGINX as long as you specify different locations and names. Each of which could even have it's own init or systemd script (though you'd most likely need to modify the ones that come along with the compile or create your own).

When doing a non-standard build, you may also need to create the directories first, otherwise the build may error out since you're telling NGINX to use directories that do not yet exist.

Have another answer? Share your knowledge.