Create a NginX Server Block

Name: * PHP Version:

Create a Server Block.


Create your folder where your website is stored.
$ sudo mkdir -p /var/www/
Now we assign the rights to the current user. Please do not run as root.
$ sudo chown -R $USER:$USER /var/www/
After that we adjust the permissions.
$ sudo chmod -R 755 /var/www
Now we copy the server block file.
$ sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/
Modify the file as shown. If a required line has a # in front of it, it must be removed.
/etc/nginx/sites-available/

server {
        listen 80;
        listen [::]:80;
        index index.php index.html index.htm;
        server_name  www.;

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


        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }
}
Enable the Server Block.
$ sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
To prevent possible problems we change something in the nginx.conf.
$ sudo nano /etc/nginx/nginx.conf
We search for server_names_hash_bucket_size with CTRL-W and remove the #.
/etc/nginx/sites-available/

http {
    . . .

    server_names_hash_bucket_size 64;

    . . .
}
To test if we made a mistake, we use this command.
$ sudo nginx -t
If no problems are found, Nginx can be restarted.
$ sudo systemctl restart nginx