1.Installing Nginx
$ sudo apt update $ sudo apt install nginx
2.Adjusting the Firewall
$ sudo ufw app list Available applications: CUPS Nginx Full Nginx HTTP Nginx HTTPS
- Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
- Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)
- Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)
$ sudo ufw allow 'Nginx Full' $ sudo ufw allow 'Nginx HTTP'
$ sudo ufw status Status: inactive
$ sudo ufw enable
$ sudo ufw status Status: active To Action From -- ------ ---- Nginx Full ALLOW Anywhere Nginx HTTP ALLOW Anywhere Nginx Full (v6) ALLOW Anywhere (v6) Nginx HTTP (v6) ALLOW Anywhere (v6)
เปิดพอร์ทแบบกำหนดไปเลย
$ sudo ufw allow 22/tcp $ sudo ufw allow 80/tcp $ sudo ufw allow 443/tcp
3.Checking your Web Server
$ systemctl status nginx
● 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 Thu 2020-02-06 14:26:15 +07; 33min ago
Docs: man:nginx(8)
Main PID: 5720 (nginx)
Tasks: 5 (limit: 4915)
CGroup: /system.slice/nginx.service
├─5720 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─5721 nginx: worker process
├─5722 nginx: worker process
├─5723 nginx: worker process
└─5724 nginx: worker process