How to Install Nginx Mainline Versions on Ubuntu

Nginx has two primary repositories or branches that folks can use to install or update Nginx packages. When you install Nginx from Ubuntu’s default repositories, you’re installing Nginx from the stable repository.

At times, Ubuntu repositories won’t have the latest stable version of Nginx either. So you’re probably a bit behind when you install from the default repositories that come with Ubuntu.

The two branches of Nginx to install from are, the stable and development or mainline branch.

Folks will tell you not to install Nginx from the mainline branch on your production servers and to only install Nginx from the stable branch.

I personally use Nginx’s mainline branch in production. In fact, this website is running on the latest version of Nginx which can only be installed from the mainline branch. Packages in the mainline branch are not considered untested or unreliable. They are stable to use in your environments.

In some cases, new features are only available in the mainline branch and if you need to enable these features you will need to install Nginx from that branch before they get promoted to the stable branch.

This brief tutorial is going to show students and new users steps to add Nginx mainline repository to Ubuntu and install Nginx from there.

Step 1: Adding Nginx Mainline’s Repository to Ubuntu 16.10

Before you can install packages from Nginx’s mainline branch, you must first install its repository. To do that, run the commands below to download the repository authentition key

cd /tmp/ && wget

Nginx run the command below to install the key on your machine.

sudo apt-key add nginx_signing.key

Step 2: Adding the Mainline Repository

After installing Nginx’s repository authentication key, go and create a repository file. To do that, run the commands below:

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

The commands above create a repository file in the /etc/apt/sources.list.d directory called Nginx.list

Step 3: Installing Nginx from Mainline

When the file is created, all you have to do is to update your system and install the latest version of Nginx. To do that run the commands below

sudo apt-get update
sudo apt-get install nginx

That’s it!

This is how one installs Nginx from its mainline repository or branch.

You may also like the post below:

1 Comment

  1. What if I need to use some additional modules, headers more, for example? – How to install additional modules with customer installed nginx mainline?

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.