How to install latest Nginx on Ubuntu

Nginx Logo

Ubuntu doesn’t always keep up with the latest stable releases of Nginx. To install latest Nginx on Ubuntu I normally follow these steps:

Step 1

Add latest stable release distro to Ubuntu sources file in /etc/apt/sources.list. Replace ‘precise’ with your Ubuntu version:

echo 'deb precise nginx' >> /etc/apt/sources.list

Step 2

Add public key from Ubuntu server

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

Step 3

Update Ubuntu packages

apt-get update

Step 4

Install latest Nginx

sudo apt-get install nginx

Optionally, if you are upgrading from an older version you would need to remove nginx-full and nginx-common packages as they will conflict with a new version. You would do this before Step 3. If you do upgrade, it’s always good practice to backup your Nginx config files before you upgrade.