Install Nginx on Debian/ Ubuntu

Install Nginx on Debian/ Ubuntu

Category : How-to

Get Social!

nginx-logoInstalling Nginx on Debian or Ubuntu is as easy as a single apt-get command, however it does not install the latest version of Nginx. In fact, the latest stable Nginx version is 1.8 and the latest package in Debian’s standard repository is 1.2

To get the latest stable version we need to add a new source to our package manager. Before doing so, add the Nginx PGP key which is used to sign all packages. Run the below commands to download the key from Nginx.com, add it to our package manager and clean up the local downloaded file.

wget http://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
rm nginx_signing.key

We can now create the new source file with the Nginx repository location.

vi /etc/apt/sources.list.d/nginx.list

Add one of the following depending on your Linux distribution. You will need to change wheezy or trusty to the codename of your distribution version.

Debian

deb http://nginx.org/packages/debian/ wheezy nginx
deb-src http://nginx.org/packages/debian/ wheezy nginx

Ubuntu

deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx

 

Finally, update your local repository cache and install Nginx.

apt-get update
apt-get install nginx

Run -v on nginx and you should see something like version 1.8.0.

nginx -v
nginx version: nginx/1.8.0

 


2 Comments

windsor

19-Jun-2015 at 4:09 pm

Hey James, small typo: should be:
vi /etc/apt/sources.list.d/nginx.list
^

    james.coyle

    19-Jun-2015 at 5:14 pm

    Thanks for mentioning it – I’ve updated the post.

Leave a Reply

Visit our advertisers

Quick Poll

What type of VPN protocol do you use?

Visit our advertisers