How to get the latest nginx on Ubuntu 12.04.2 LTS (Precise Pangolin)

Published in: HowTo

I love Nginx, it’s fast, easy to configure, low footprint. It’s also regularly updated with new features. Unfortunately, the server package managers are almost never in sync with the latest updates. I use the current Ubuntu LTS (12.04 Precise Pangolin) as my preferred server of choice. However the current Nginx version on Precise is 1.1.19, there is nothing wrong with this version, but it is not the bleeding edge with the all the bells and whistle.

To get the latest stable Nginx release on your Ubuntu 12.04 server you have to do this.

1) Add the official nginx repository:

Add deb precise nginx to your package source list /etc/apt/sources.list

2) Add public key for your package from ubuntu server:

sudo apt-key adv --keyserver --recv-keys ABF5BD827BD9BF62

3) Remove current nginx install:

You have to remove nginx-full and nginx-common as they will conflict with the new version. Don’t worry your server configs won’t be removed. Do a sudo apt-get update for good measure.

4) Install nginx from new repository:

Simply install nginx with apt-get install nginx

One thing to note is that Nginx package from Ubuntu use /etc/nginx/sites-available/ to store site configs but package from Nginx stores configs files in /etc/nginx/conf.d/. Even though you get an option to keep your current Nginx config or overwrite during installation, it’s always a good idea to backup your config files before installing/upgrading to a newer version of nginx.

Finally, check to see if you are using the current nginx. As of this writing for me its:

nginx -v
nginx version: nginx/1.4.1

about | twitter | facebook | archive | rss