First, download the NGINX signing key for the packages and install it:
wget http://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
Then, using your preferred Linux editor, we can add the sources to /etc/apt/sources.list.d/nginx.list:
deb http://nginx.org/packages/mainline/debian/ codename nginx
deb-src http://nginx.org/packages/mainline/debian/ codename nginx
Replace codename with the release name; for example, if you're using Debian 8, this will be set to jessie.
For Ubuntu-based systems, you'll need to use the following:
deb http://nginx.org/packages/mainline/ubuntu/ codename nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ codename nginx
Replace codename with the release name; for example, if you're using Ubuntu 14.04, this will be set to trusty.
After adding the new source, we can then update the apt database and install NGINX:
apt-get update
apt-get install nginx
Installation should now be complete.