A common topic for beginners on how to host a simple HTML website in Nginx. I am a great fan of Nginx for its capability, performance, and simplicity.
Let’s go through some insights including installation and path structure.
INSTALL NGINX ON UBUNTU:
That’s it! Thanks, Ubuntu keeping Nginx in its apt repository.
ENABLE NGINX ON FIREWALL :
We need to allow Nginx to use HTTP [port 80] at the firewall.
If you are using Server instances from AWS, they have a security layer that acts as a security firewall. you might have noted something like configuring
`Security Groups` this while creating an instance in AWS. In that case, altering ubuntu’s built-in firewall [ command ‘
sudo ufw [options]‘] might cutdown ssh access to the server. So my suggestion is if you are not sure what’s going to happen, just ignore `ufw` commands in servers.
To view list of applications which request for the port, run :
After installing Nginx, this command will return something like:
enable Nginx HTTP access by.
View the list of allowed applications.
If the terminal shows
Status: inactive that means the firewall is off. you do not have to bother about them. Else the output will be something like.
When an application is put in daemon mode, ubuntu has some built-in monitoring applications.
init.d e.t.c. My favorite is
This will output something similar to:
● 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 Fri 2019-12-13 10:09:53 IST; 5h 1min ago Docs: man:nginx(8) Process: 1416 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 1503 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 1505 (nginx) Tasks: 5 (limit: 4915) Memory: 7.1M CGroup: /system.slice/nginx.service ├─1505 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; ├─1506 nginx: worker process ├─1507 nginx: worker process ├─1508 nginx: worker process └─1509 nginx: worker process
Now go to browser and open `http://localhost` or `http://<ip.address>` or `http://<domain.name>` to open nginx home page.
Stop, Start or Restart by :
Know Server Status by :