Upgrading Your Version of Nginx

Ubuntu repositories can become outdated due to package freezing before official releases. You might want to use the latest and greatest versions of Nginx.

When you’re on an LTS (Long Term Support) version of Ubuntu, such as 12.04 or 14.04, the repositories that are included may not be fully up-to-date. Using Ubuntu 12.04, the version of Nginx that comes in the source package is 1.1.19, while the latest stable version at the time of this writing is 1.6.0. You can see your version of Nginx with

nginx -v

If you want some of the newer features with the later version additions of Nginx, you’ll need to append a couple of lines to your sources.list (/etc/apt/sources.list). We’ll be using a PPA (personal package archive) from Launchpad.

sudo nano /etc/apt/source.list

Paste the following, but change precise to your version of Ubuntu (such as trusty, saucy, raring, and so on). This is for 12.04, precise.

deb http://ppa.launchpad.net/nginx/stable/ubuntu precise main 
deb-src http://ppa.launchpad.net/nginx/stable/ubuntu precise main

Now let’s fetch the PPA keys.

sudo add-apt-repository ppa:nginx/stable

And we’re done. Go ahead and update and install.

sudo apt-get update
sudo apt-get install nginx

If you already have Nginx installed, you’ll be asked a couple of questions. If you’ve changed your configs, make sure you say no when it asks if you want to use the settings from the new package.