Report this

What is the reason for this report?

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

Posted on June 7, 2016

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)



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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/)

@lexgabrees

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.

When you compile and install a different version of NGINX, several considerations come into play regarding the existing installation, configuration files, and virtual hosts. Here’s a detailed guide on how to handle this process:

Considerations for Compiling and Installing a New Version of NGINX

Overwriting vs. Removing the Previous Version:

  • Overwriting: Compiling and installing a new version of NGINX can overwrite the existing binaries if installed to the same location. This is generally like updating the previous version.
  • Removing the Previous Version: It’s often cleaner to remove the old version first to avoid conflicts, especially if there are significant differences between the versions.

Configuration Files and Virtual Hosts:

  • The new installation process should not overwrite your existing configuration files (/etc/nginx/nginx.conf and /etc/nginx/sites-available/).
  • However, it’s always good practice to back up your existing configuration files before proceeding with the installation.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.