Install / Upgrade to Nginx HTTP Server Current Latest on Ubuntu 16.04 LTS Server

All my Nginx HTTP servers always upgrade to the latest when they become available… I get them because I’ve added Nginx Mainline repository to my systems… so the latest and greatest are always available to me.

For those webmasters wanting get Nginx latest version as soon as they’re released, the steps below is a good starting point.

This brief post shows students and new users how to add Nginx mainline repository to Ubuntu to always get the latest version when they become available…. Although the latest versions have been stable for me, it may not be the same for you… so make sure your environment is ready for it.

Ubuntu default repositories have Nginx stable version… should be good to run in production environments. If you still want to upgrade to the latest, then continue below:

To install Nginx from Ubuntu repository, run the commands below:

sudo apt-get install nginx

After running the commands above, Nginx should be installed and ready to use, but won’t be from the mainline repository of Nginx.

Step 1: Installing Nginx from its Repository

To install Nginx from its repostory, you must add it to Ubuntu. You first add the repository key and then the repository. The key is there so Ubuntu can validate that the packages downloading from Nginx’s repository are trusted.

To install the key, run the commands below.

cd /tmp/ && wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key

After adding the repository key, the two repository below can get Nginx installed.

Nginx has two repositories. They are, Stable and Mainline repositories.

Nginx’s Mainline repository contains the latest packages. The Stable repository contains packages that are not the latest, but those that are tested to work in many different environments. Nginx’s mainline repository as a place new features get introduced.

After packages and features in the current mainline repository are tested and proven, the repository is then promoted to the latest stable and a new mainline is created.

Adding Nginx Mainline Repository

To add Nginx Mainline repository to Ubuntu, run the commands below:

sudo sh -c "echo 'deb http://nginx.org/packages/mainline/ubuntu/ '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/NginxMainline.list"

Then run the commands below to install Nginx.

sudo apt-get update
sudo apt-get install nginx

Adding Nginx Stable Repository

To add Nginx Stable Repository to Ubuntu, run the commands below

sudo sh -c "echo 'deb http://nginx.org/packages/stable/ubuntu/ '$(lsb_release -cs)' nginx' > /etc/apt/sources.list.d/NginxStable.list"

Then run the commands below to install Nginx

sudo apt-get update
sudo apt-get install nginx

If both Nginx mainline and stable repositories are added to Ubuntu, packages will be installed from Nginx mainline repository because they’re the latest.

To validate Nginx version, run the commands below

sudo nginx -v
nginx version: nginx/1.13.8

Summary:

This post shows students and new users how to install the latest versions of Nginx on Ubuntu server. Nginx has two primary repositories. The Stable and Mainline repositories. The mainline repository is where newer features and packages get introduced.

The stable repository has packages that are tested and proven to work in many environments.

Enjoy!

You may also like the post below:

Install / Upgrade to MariaDB 10.1 / 10.2 / 10.3 Latest on Ubuntu 16.04 LTS Server

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.