How to install NGINX in ubuntu

Published: 19 December 2022
on channel: Quickloss3
451
26

Install Nginx on Ubuntu

Installing Nginx:
sudo apt update && apt upgrade -y
sudo apt install nginx -y


Adjusting the Firewall:
sudo ufw allow 'Nginx HTTP'
sudo ufw allow 'openSSH'


Checking your Web Server:
systemctl status nginx
curl -4 icanhazip.com

http://server_ip

Managing the Nginx Process:
stop your web server:
sudo systemctl stop nginx

start the web server when it is stopped:
sudo systemctl start nginx

restart the service again:
sudo systemctl restart nginx

reload without dropping connections:
sudo systemctl reload nginx

By default, Nginx is configured to start automatically when the server boots. If this is not what you want, you can disable this behavior:
sudo systemctl disable nginx

re-enable the service to start up at boot:
sudo systemctl enable nginx


Setting Up Server Blocks:
sudo mkdir -p /var/www/your_domain/html
sudo chown -R $USER:$USER /var/www/your_domain/html
sudo chmod -R 755 /var/www/your_domain
nano /var/www/your_domain/html/index.html

paste
(watch video)

sudo nano /etc/nginx/sites-available/your_domain

paste
server {
listen 80;
listen [::]:80;

root /var/www/your_domain/html;
index index.html index.htm index.nginx-debian.html;

server_name your_domain www.your_domain;

location / {
try_files $uri $uri/ =404;
}
}

sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/

sudo nano /etc/nginx/nginx.conf
...
http {
...
server_names_hash_bucket_size 64;
...
}
...

sudo nginx -t

sudo systemctl restart nginx

http://your_domain


Watch video How to install NGINX in ubuntu online without registration, duration hours minute second in high quality. This video was added by user Quickloss3 19 December 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 451 once and liked it 26 people.