Nginx is a fast, powerful and secure HTTP server. It’s used by many webmasters looking to improve their website performance. Most people even think it’s better than Apache2 in the way it handles web traffic. In this brief blog post, I am going to show you how to install the latest version of Nginx web server on Ubuntu 14.10.

We are currently using Nginx to speed up our website loading time and we’re impressed. Using Nginx with Memcached, one can achieve great performance.

Installing Nginx on Ubuntu is easy. By default, all you have to do is run Ubuntu apt-get install nginx command. This will download and install Nginx for you.

The downside is, the version that’s stable in Ubuntu software repository isn’t the latest. It’s pretty old but reliable and stable. If you want the latest, you must add additional repositories to your system.

Nginx has two separate repositories. One is known as stable and the other is mainline.

The mainline repository contains the most recent updates that are not included in the stable repository. The mainline repository is like a testing ground for newly released features. When those features are thoroughly tested and proven, they are then included in the stable repository.

If you want to test Nginx latest features, then you’ll have to install the mainline repository for your system. You won’t find them in Nginx stable repository.

So, to get started with getting the latest Nginx for Ubuntu, continue below.

 

  • Adding Nginx Mainline repository

I said earlier that Nginx latest version is added to the mainline repository. To add that repository to your Ubuntu machines, run the commands below to create a separate repository file for Nginx.

Before that, run the commands below to download Nginx repository authentication key.

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

Next, run the commands below to install the repository key

sudo apt-key add nginx_signing.key

Installing installing the repository key, run the commands below to create a new repository file for Nginx

sudo vi /etc/apt/sources.list.d/nginx.list

Then copy and paste the lines below into the file and save it.

deb http://nginx.org/packages/mainline/ubuntu/ codename nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ codename nginx

Replace codename with Ubuntu codename for releases  (ex. 14.10 is known as Utopic)

To view Ubuntu development codenames, check this page out.

If Nginx hasn’t been updated its repository for the particular version of Ubuntu, you can try a previous codename. This worked for me when the latest version of Nginx wasn’t yet available for Ubuntu 14.10.

Finally, run the commands below to install Nginx

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

 

That’s it! This is how you install the latest version of Nginx on Ubuntu 14.10. This tutorial also applies to earlier version of Ubuntu. It may apply to future version of Ubuntu if Nginx repositories don’t change.

Enjoy!