How to Install Nginx using ubuntu 16.04


Nginx is an free and open-source web server, nginx can also be used as a reverse proxy server, load balancer, mail proxy, HTTP cache and more.

On this tutorial, We will install and configure Nginx web server using Ubuntu 16.04 machine.

Install Nginx

Step 1:- You need to update the ubuntu default repo and install the nginx by following the commands.

sudo -i
apt-get update
apt-get install nginx -y

After installation process, You need to check the nginx service status by using the following commands.

systemctl status nginx

You should get the outpu like this :-

● nginx.service – A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-12-15 16:11:04 IST; 2min 01s ago
 Main PID: 1001 (nginx)
   CGroup: /system.slice/nginx.service
           ├─1001 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
           └─1002 nginx: worker proces

Update UFW firewall

By default nginx using port 80, If you have ufw enabled in your machine so then you need to add the port 80 by following the commands.

ufw allow 80
ufw status

After this you should get commands output like this :-

Status: active

To                         Action      From
—                         ——      —-
80/tcp                     ALLOW       Anywhere

Testing the nginx web server

If nginx is successfull installed and nginx service is on Running status so then you need to open the browser with http://localhost:80 you should get web page like this :-

Controlling nginx service 

To start the nginx service use the following command.

systemctl start nginx

To check status of nginx service use the following command.

systemctl status nginx

To reload the nginx service use the following command. 

systemctl reload nginx

To stop nginx service use the following command.

systemctl stop nginx

To start on boot nginx service use the following command.

systemctl enable nginx

To stop on boot nginx service use the following command.

systemctl disable nginx

How to Install Nginx using ubuntu 16.04

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top