zondag 28 februari 2021

nginx setup ubuntu

 update repositories:

sudo apt-get update

install nginx

sudo apt-get install nginx

check version of nginx

nginx -v

check status of nginx

sudo systemctl status nginx

start nginx

sudo systemctl start nginx

stop nginx : sudo systemctl stop nginx

set nginx to start at reboot server / system starts:

sudo systemctl enable nginx

when to disable at system start: sudo systemctl disable nginx

reload nginx after configuration is changed:

sudo systemctl reload nginx

hard restart of nginx:

sudo systemctl restart nginx

installeer 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:

install curl: sudo apt-get install curl
run check: curl -i http://127.0.0.1

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/html

create index.html and fill it with contents:

sudo nano /var/www/test_domain.com/html/index.html

Edit configuation for the site, all configuration is located in /etc/nginx/sites-available

sudo nano /etc/nginx/sites-available/test_domain.com

nice article to follow:

https://phoenixnap.com/kb/how-to-install-nginx-on-ubuntu-20-04


Geen opmerkingen:

Een reactie posten