Some distribution like Ubuntu use stable release from Nginx. Sometimes, if you use the default OS repositories, you cannot get the latest version from nginx. This is because Nginx has two main active branch of package release which are Mainline and Stable release. There is also another branch release which is Legacy nginx package.

Depends on the operating system, some forks on stable nginx package which minimize the potential bugs and some use bleeding edge that use the mainline nginx package to get the most out from nginx.

Mainline vs Stable release

In stable release, Nginx commits only major bug fixes and stable features correspond to that version. If new version coming out, it will come with the new stable features from the previous Mainline release.

While the mainline release is an active branch which commits many new features, major updates and bug fixes.

Version numbering

You can check if you're using mainline or stable release by issuing the following command:

$ nginx -v
nginx version: nginx/1.13.12
  • The even‑numbered version (1.12) is using Nginx stable branch. This branch is updated only when critical issues or security vulnerabilities need to be fixed.
  • The odd‑numbered version (1.13) is the mainline branch. This branch is actively developed; new minor releases (1.13.1, 1.13.2, etc.) are made approximately every 4 to 6 weeks, regularly introducing new features and enhancements.

As describe in Nginx blog:

We generally recommend using the mainline branch. This is where we commit all new features, performance improvements, and enhancements

How to get Nginx from the Mainline release

For this example, I'm using Ubuntu 16.04.

  1. Download nginx_signing.key. This key is used by the apt program to sign the nginx package and authenticate to the nginx server repository. It is a must to prevent any warnings and errors during package installation.
$ wget
$ sudo apt-key add nginx_signing.key
  1. Get your Ubuntu codename. If you're using 16.04 your codename is xenial. Else, you can check that by using the command below.
$ . /etc/os-release 
$ echo $VERSION | awk -F " " '{ print tolower(substr($3,2)) }'
  1. Edit /etc/apt/sources.list as sudo and add the following at the bottom of the file. Replace the codename with your codename you get from above command. You can uncomment the deb-src if you want to access the sources package.
deb codename nginx
# For source package access, uncomment the following line
#deb-src codename nginx
  1. Update your package and install Nginx. Note: If you already has nginx installed, you need first to uninstall current nginx package before downloading (installing) the new one. The current package will not get automatically updated to the newer package found in nginx repository.
$ sudo apt update
$ sudo apt install nginx

Read more references here: