How to install Nginx on Ubuntu & Securing with Let's Encrypt

Published: 21 December 2022
on channel: Quickloss3
480
22

Update Server:
sudo apt update && apt upgrade -y

Installing Nginx:
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

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

Secure Nginx with Let's Encrypt on Ubuntu

Installing Certbot:
sudo snap install --classic certbot

create a symbolic link to the newly installed /snap/bin/certbot:
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Confirming Nginx’s Configuration:
sudo nano /etc/nginx/sites-available/your_domain
if not then update and save it
sudo nginx -t
sudo systemctl reload nginx

Allowing HTTPS:
sudo ufw status
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo ufw status

Obtaining an SSL Certificate:
sudo certbot --nginx -d your_domain


Watch video How to install Nginx on Ubuntu & Securing with Let's Encrypt online without registration, duration hours minute second in high quality. This video was added by user Quickloss3 21 December 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 480 once and liked it 22 people.