How to Install Nginx using ubuntu 16.04 - TechBeginner

Welcome to TechBeginner.in, Tech Beginner provides technical blog for Online Linux Tutorials, Ubuntu Tutorials, Redhat Tutorials and CentOS 7, Configuration of server like Web Server, Application server, Database server, Window server, networking, html, css, java script, php, wordpress, opencart, magento, joomla and etc.

How to Install Nginx using ubuntu 16.04

Share This

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



No comments:

Post a Comment