I’ll introduce the steps to install the latest stable Nginx version v1.12.0 on Ubuntu LTS 16.04.
 
Use the apt-cache policy command to check the available Nginx versions for installation.
$ apt-cache policy nginx
nginx:
  Installed: (none)
  Candidate: 1.10.0-0ubuntu0.16.04.4
  Version table:
     1.10.0-0ubuntu0.16.04.4 500
        500 http://mirrors.linode.com/ubuntu xenial-updates/main amd64 Packages
        500 http://mirrors.linode.com/ubuntu xenial-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
     1.9.15-0ubuntu1 500
        500 http://mirrors.linode.com/ubuntu xenial/main amd64 Packages
        500 http://mirrors.linode.com/ubuntu xenial/main i386 Packages
Before adding the key, check the current list of keys with the apt-key list command.
$ apt-key list
/etc/apt/trusted.gpg
--------------------
pub   1024D/437D05B5 2004-09-12
uid                  Ubuntu Archive Automatic Signing Key 
sub   2048g/79164387 2004-09-12
pub   4096R/C0B21F32 2012-05-11
uid                  Ubuntu Archive Automatic Signing Key (2012) 
pub   4096R/EFE21092 2012-05-11
uid                  Ubuntu CD Image Automatic Signing Key (2012) 
pub   1024D/FBB75451 2004-12-30
uid                  Ubuntu CD Image Automatic Signing Key 
    
Download the key distributed by the Nginx official site using curl command and add it with apt-key add command.
curl http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
Check again with apt-key list command to confirm that the nginx signing key has been added.
$ sudo apt-key list
/etc/apt/trusted.gpg
--------------------
pub   1024D/437D05B5 2004-09-12
uid                  Ubuntu Archive Automatic Signing Key 
sub   2048g/79164387 2004-09-12
pub   4096R/C0B21F32 2012-05-11
uid                  Ubuntu Archive Automatic Signing Key (2012) 
pub   4096R/EFE21092 2012-05-11
uid                  Ubuntu CD Image Automatic Signing Key (2012) 
pub   1024D/FBB75451 2004-12-30
uid                  Ubuntu CD Image Automatic Signing Key 
pub   2048R/7BD9BF62 2011-08-19 [expires: 2024-06-14]
uid                  nginx signing key 
     
Add the Nginx repository to /etc/apt/sources.list.
Change the xenial part to match your OS version.
sudo sh -c "echo 'deb http://nginx.org/packages/ubuntu/ xenial nginx' >> /etc/apt/sources.list"
sudo sh -c "echo 'deb-src http://nginx.org/packages/ubuntu/ xenial nginx' >> /etc/apt/sources.list"
Run apt-get update before installation.
sudo apt-get update
Check again with apt-cache policy command to confirm that the latest stable Nginx 1.12.0 is now available for installation.
$ apt-cache policy nginx
nginx:
  Installed: (none)
  Candidate: 1.12.0-1~xenial
  Version table:
     1.12.0-1~xenial 500
        500 http://nginx.org/packages/ubuntu xenial/nginx amd64 Packages
     1.10.3-1~xenial 500
        500 http://nginx.org/packages/ubuntu xenial/nginx amd64 Packages
     1.10.2-1~xenial 500
        500 http://nginx.org/packages/ubuntu xenial/nginx amd64 Packages
     1.10.1-1~xenial 500
        500 http://nginx.org/packages/ubuntu xenial/nginx amd64 Packages
     1.10.0-1~xenial 500
        500 http://nginx.org/packages/ubuntu xenial/nginx amd64 Packages
     1.10.0-0ubuntu0.16.04.4 500
        500 http://mirrors.linode.com/ubuntu xenial-updates/main amd64 Packages
        500 http://mirrors.linode.com/ubuntu xenial-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
     1.9.15-0ubuntu1 500
        500 http://mirrors.linode.com/ubuntu xenial/main amd64 Packages
        500 http://mirrors.linode.com/ubuntu xenial/main i386 Packages
Finally, install Nginx.
sudo apt-get install nginx
Check the Nginx version after installation.
$ nginx -v
nginx version: nginx/1.12.0
That’s it.
That’s all from the Gemba.