update repositories:
sudo apt-get updateinstall nginx
sudo apt-get install nginxcheck version of nginx
nginx -vcheck status of nginx
sudo systemctl status nginxstart nginx
sudo systemctl start nginxstop nginx : sudo systemctl stop nginx
set nginx to start at reboot server / system starts:
sudo systemctl enable nginxwhen to disable at system start: sudo systemctl disable nginx
reload nginx after configuration is changed:
sudo systemctl reload nginxhard restart of nginx:
sudo systemctl restart nginxinstalleer firewall:
sudo apt-get install ufw
start/enable firewall:
sudo ufw enable
check apps in firewall:
sudo ufw app list
Enable nginx http calls through the firewall:
sudo ufw allow 'nginx http'Enable nginx https: sudo ufw allow 'nginx https'
to enable http and https: sudo ufw allow 'nginx full'
after setting reload firewall: sudo ufw reload
Check if nginx server is running using curl:
DON'T FORGET TO OPEN PORT 22 for SSH
sudo ufw allow 22/tcp
or sudo ufw allow ssh
In Nginx, a server block is a configuration that works as its own server. By default, Nginx has one server block preconfigured.
It is located at /var/www/html. However, it can be configured with multiple server blocks for different sites.
Create testdomain/testwebsite:
sudo mkdir -p /var/www/test_domain.com/htmlcreate index.html and fill it with contents:
sudo nano /var/www/test_domain.com/html/index.htmlEdit configuation for the site, all configuration is located in /etc/nginx/sites-available
sudo nano /etc/nginx/sites-available/test_domain.comnice article to follow:
https://phoenixnap.com/kb/how-to-install-nginx-on-ubuntu-20-04