Kategorie: Linux

Installing Nginx in Ubuntu 20.04 LTS

The guide below describes how to install the Nginx web server on Ubuntu 20.04 LTS
We will do the whole thing through the console in a few minutes.

We start the terminal and update and install the nginx server

sudo apt update
sudo apt install nginx

We add the web server to the firewall:

sudo ufw allow 'Nginx HTTP'

We can verify the status of the Nginx service by issuing the command:

systemctl status nginx

An example result is shown below:

Output
● 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 Fri 2020-04-20 16:08:19 UTC; 3 days ago
     Docs: man:nginx(8)
 Main PID: 2369 (nginx)
    Tasks: 2 (limit: 1153)
   Memory: 3.5M
   CGroup: /system.slice/nginx.service
           ├─2369 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           └─2380 nginx: worker process

Now we will start creating the file structure for the vhost:

We create the directory structure:

sudo mkdir -p / var / www / our_domain / html

We give permission:

sudo chown -R $USER:$USER / var / www / our_domain / html

We set chmod

sudo chmod -R 755 /var / www / ourdomain

We create an example index.html of our website to validate our configuration:

nano /var/www/nasza_domena/html/index.html

Contents:

    
        Welcome to domena.pl!
    
    
        

Success! Everything works correctly!

save the file.

We create a new vhost:

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

And the content:

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

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

        server_name our_domain www.our_domain;

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

We're making a symbolic link:

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

We edit the nginx configuration file

sudo nano /etc/nginx/nginx.conf

And we uncomment the line:

server_names_hash_bucket_size

The whole should look like:

...
http {
    ...
    server_names_hash_bucket_size 64;
    ...
}
...

restart the nginx server, our vhost should work properly.

sudo systemctl restart nginx

Linux

Udostępnij
Opublikowane przez
Linux

Recent posts

KeePass2 2.52 w Ubuntu 22.04

The guide below describes how to install KeePass on Ubuntu. Całość wykonamy za pomocą kilku poleceń

2 years temu

Installing Master PDF editor in Ubuntu 22.04

Master PDF Editor is a comprehensive PDF program, which includes many features. Oprócz tworzenia i edycji

2 years temu

iotop - memory monitoring

Iotop jest prostym narzędziem dla systemów Uniksowych umożliwiającym monitorowanie użycia dowolnego nośnika pamięci flash/hdd/ssd w

2 years temu

Run multiple commands in one cron job

You can separate two or more commands with semicolons (;), Semicolon (;): służy do oddzielania

2 years temu

Changing the exif data of a photo in the Linux terminal

Poniższy poradnik opisuje w jaki sposób za pomocą konsoli możemy dokonać edycji danych zdjęcia exif.

2 years temu

Installing Rocket.Chat Server on Rocky Linux 8

The following guide describes how to install Rocket.Chat on Rocky Linux 8 Całość bardzo prosto zainstalujemy

2 years temu