Installing and Configuring Nginx on Debian 12

Installing and Configuring Nginx on Debian 12
В
Written by Вікторія
Updated 4 days ago

UPDATE THE SYSTEM

sudo apt update

INSTALL NGINX

sudo apt install nginx -y

START AND ENABLE NGINX ON BOOT

sudo systemctl start nginx
sudo systemctl enable nginx

CHECK IF IT'S RUNNING
Open your browser and go to your server’s IP address:

http://your_IP

CREATE A CONFIGURATION
Create a new configuration file for your site:

sudo nano /etc/nginx/sites-enabled/mysite

Insert the following example configuration:

server {
    listen 80;
    server_name example.com www.example.com;

    root /var/www/mysite;
    index index.html index.htm;

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

CREATE THE SITE DIRECTORY AND A TEST PAGE

sudo mkdir -p /var/www/mysite
echo 'Your test greeting from the Nginx configuration!' | sudo tee /var/www/mysite/index.html
sudo systemctl reload nginx

Your server is now running with Nginx.
If needed, you can edit /etc/nginx/nginx.conf or individual site configuration files in sites-available.

Did this answer your question?