Install latest version of Nginx on Ubuntu

NginxI always run the latest LTS version of Ubuntu on all my servers. Unfortunately, the Nginx versions tend to be quite the bit behind the current release. So how do you get an updated, current version of without resorting to having to maintain the packages yourself? Luckily, the Nginx team have their own Ubuntu apt repository so it’s easy to keep current with the latest version of Nginx.

Advertisement:

In general, you should deploy the NGINX mainline branch at all times.  You may wish to use stable if you are concerned about possible impacts of new features, such as incompatibility with third-party modules or the introduction of bugs in new features.

Source: NGINX 1.6 and 1.7 released – Which version should I use?

First, to avoid missing PGP key during installation and upgrades, install the Nginx team’s package signing key:

$ curl -s https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

Add the repo to your apt sources:

$ sudo echo -e "deb https://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx\ndeb-src https://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx" > /etc/apt/sources.list.d/nginx.list

Resynchronize the package index files from their sources:

$ sudo apt-get update

If you are installing nginx:

$ sudo apt-get install nginx

… or if you are upgrading:

$ sudo apt-get dist-upgrade

And you’re done :-)

Maybe you are also looking for how to install the latest version of PHP?
… or even replace PHP with HHVM.


By the way: If you want hassle-free, amazingly fast web hosting, you should check out Servebolt (affiliate link). They’ll even transfer your site for free.


There are 13 comments

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.