How to Install Nginx Latest Version on Ubuntu 16.10 / 17.04

Ubuntu comes with Nginx webserver packages in its default repositories. If one wants to install Nginx webserver, all he/she has to do is run the sudo apt-get install nginx command and a stable version of Nginx will be installed.

However, installing Nginx packages from Ubuntu default repositories won’t install the latest version of Nginx webserver. Although the stable version is highly recommended to run a production environment, Nginx mainline version is also tested and production ready.

For those who want to run the latest versions of Nginx webserver will need to install from its repositories.

This brief tutorial shows users and students how to install the latest versions of the server when running Ubuntu.

Step 1: Add Nginx’s repository public key to Ubuntu

To install Nginx from its default repositories, you must add the repository keys to Ubuntu. Doing this tells the Ubuntu machine that the repositories the packages are being downloaded from are trusted.

To add the key, run the commands below.

cd /tmp/ && wget

After downloading the key, run the commands below to install it.

sudo apt-key add nginx_signing.key

Step 2: Creating Nginx’s repository file definitions

Now that the repository public key is installed, the next step is to create the local repository file which will contain Nginx’s repository definitions. Since we want to install the latest version Nginx, we’ll be adding the mainline repository.

For the stable version, change mainline to stable.

Nginx Mainline repository contains the latest version of Nginx packages.

To add Nginx Mainline repository file, run the commands below

sudo sh -c "echo 'deb '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/Nginx.list"

After that continue below to install Nginx

Step 3: Installing Nginx

Now that the local repository file is added, run the commands below to update your system and install Nginx

sudo apt-get update
sudo apt-get install nginx

This is how one installs the latest version of Nginx on Ubuntu

Enjoy and please come back soon.

You may also like the post below:


  1. Thanks for the detailed information. Worked perfectly.

  2. Worked the first time. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.