Gordan Jandreoski

Gordan Jandreoski


var blog = { "dev", "cloud", "tech", "geek", null};

Newsletter Subscribe


Tags


How to install latest version (mainline) of nginx on Ubuntu

Gordan JandreoskiGordan Jandreoski

Linux tips and tricks

Nginx has two branches mainline and stable. Mainline branch has the latest version of Nginx and has all features. The stable branch is typically deployed in the LTS version of the Ubuntu server and is way back than the mainline. For production use it is recommended that you deploy the NGINX mainline branch at all times.

First install the Nginx team’s package signing key:

sudo curl http://nginx.org/keys/nginx_signing.key | apt-key add -

Add the repo to your apt sources:

echo -e "deb http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx\ndeb-src http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx" > /etc/apt/sources.list.d/nginx.list

Next update package index files from their sources

sudo apt-get update

Verify that APT is pulling from the right repository with the latest version

sudo apt-cache policy nginx

The output should be something like this

nginx:
  Installed: (none)
  Candidate: 1.11.6-1~xenial
  Version table:
     1.11.6-1~xenial 500
        500 http://nginx.org/packages/mainline/ubuntu xenial/nginx amd64 Packages
     1.11.5-1~xenial 500
        500 http://nginx.org/packages/mainline/ubuntu xenial/nginx amd64 Packages
     1.11.4-1~xenial 500
        500 http://nginx.org/packages/mainline/ubuntu xenial/nginx amd64 Packages
     1.11.3-1~xenial 500
        500 http://nginx.org/packages/mainline/ubuntu xenial/nginx amd64 Packages

You are ready to install nginx

sudo apt-get install nginx

After installation you may need to start the server

sudo systemctl start nginx

Check if the service is running with

sudo systemctl status nginx

That is all you have your NGINX web server up and running!

Comments