Virtual domain Nginx Mariadb Ubuntu localhost for local WordPress

Create a directory in /var/www/site1

in file /etc/hosts

add a line: localhost site1 www.site1 site2 www.site2 site3 www.site3


Add a file with domain name like “site1” with a code like this for PHP 8.0

server {

    root /var/www/site1;

    index index.html index.htm index.nginx-debian.html index.php;

    access_log /var/log/nginx/wordpress.woo.access.log;
    error_log /var/log/nginx/wordpress.woo.error.log;

    server_name site1 www.site1;

    location / {
            try_files $uri $uri/ /index.php?$args;

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


create simbolic link for the directroy site-enabled:

sudo ln -s /etc/nginx/sites-available/wp.disc /etc/nginx/sites-enabled/

sudo service nginx restart

sudo systemctl restart php8.0-fpm.service