Install the latest version of NginX in Ubuntu

Ubuntu is a great OS, but like many distributions the repositories are often a little behind the latest editions.

In particular i wanted to use the latest HTTP2 features in NginX. ┬áThese are available from version 1.9.5 onwards, but the ubuntu repo’s only seem to have 1.8.0 (at the time of writing)

It’s pretty easy to install the NginX.org latest stable edition:

$ curl http://nginx.org/keys/nginx_signing.key | apt-key add -
$ echo -e "deb http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx\ndeb-src http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx" > /etc/apt/sources.list.d/nginx.list
$ apt-get update
$ apt-get install nginx

OR

$ apt-get dist-upgrade