In this tutorial, we’re going to learn how to install Nginx latest version on Ubuntu. There are many web server available in the market and Nginx is one of the popular webserver being used these days.
Good news is that Nginx package is availale by default in ubuntu’s repositories. In order to install latest version of Nginx, you need to add the official Nginx repository.
Open up your sources.list file by typing following command:
sudo nano /etc/apt/sources.list
Now, press CTRL+W then CTRL+V to jump to the end of the file. After this, append the following two lines at the end of the file.
deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx
Now, import Nginx public key using the commands below.
wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key
Steps To Install Nginx:
sudo apt-get update sudo apt-get install nginx
Note: You should remove Nginx if you have installed it from Ubuntu software repository before instlling it.
sudo apt remove nginx nginx-common nginx-full nginx-core
Now after installing the Nginx, you need to unmask
nginx.service file using the command below.
sudo systemctl unmask nginx
Now start Nginx.
sudo systemctl start nginx