This tutorial will work on other debian-based systems (like Ubuntu) too.
Generally, we try to run the latest version of nginx onĀ all of our servers. Sadly, the versions of nginx included in the Raspbian and Ubuntu repositories are quite old. Luckily for us, the nginx team have their own apt repository!
So, here we go.
Let’s first install the PGP signing key:
sudo curl http://nginx.org/keys/nginx_signing.key | apt-key add -
Then add the repo to our apt sources:
sudo echo -e "deb http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginxndeb-src http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx" > /etc/apt/sources.list.d/nginx.list
…and update our index:
sudo apt-get update
Then, if you’re installing nginx:
sudo apt-get install nginx
…or just upgrading it:
sudo apt-get dist-upgrade
And then you’re done!