Lesson 29: Installing Nginx Webserver Latest on Ubuntu

Students lesson 29 assignment: How do you install Nginx webserver latest versions on Ubuntu systems?

By default Nginx stable packages are added to Ubuntu system repositories. However, Ubuntu repositories do not contain the latest versions of Nginx webserver.

If you wish to install Nginx latest version, you’ll have to manually install its repository on your Ubuntu server.

This brief tutorial is going to show you how to quickly and easily do that.

Our previous post on installing Nginx webserver can be found from the link below:

Assignment: How to Install Nginx Webserver on Ubuntu

All it takes to install Nginx on Ubuntu is to run a single line command. But to get the latest, there are extra steps needed.

Step 1: Adding Nginx webserver public key

To install Nginx webserver from its repository, you’ll need to add its public repository key to Ubuntu. Ubuntu package management system authenticates packages from the repository using the public key.

To add the public key to Ubuntu, run the commands below to download it

cd /tmp/ && wget http://nginx.org/keys/nginx_signing.key

Then, run the commands below to install the public key to Ubuntu.

sudo apt-key add nginx_signing.key

Step 2: Adding Nginx repository to Ubuntu

The next step is to add Nginx’s repository.

Before installing Nginx, here’s something to remember. Nginx has multiple repositories. Two of which are the stable repository and its mainline repository.

The stable repository contains packages that are tested and proven to work across diverse system environments. It’s the stable version of Nginx that comes with Ubuntu repositories.

The mainline repository contains newer packages and newer features that are not yet part of the latest stable packages. They are considered fit for production, but are yet to be promoted to the stable repository.

Now that the Nginx public authentication key is added, run the commands below to add its mainline repository:

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

This will add Nginx repository to a new file called Nginx.list in the /etc/apt/sources.list.d/ directory.

Step 3: Installing / upgrading Nginx

The final step after installing Nginx public authentication key and adding its repository is to install Nginx updated packages, the latest.

To install Nginx after all the steps above, run the commands below.

sudo apt-get update && sudo apt-get install nginx

That’s it!

To see which version is installed, run the command below:

nginx -v

Enjoy!

Tags: