Virtual domain Nginx Mariadb Ubuntu localhost for local WordPress

Create a directory in /var/www/site1

in file /etc/hosts

add a line:

127.0.0.1 localhost
127.0.1.1 site1 www.site1
127.0.1.2 site2 www.site2
127.0.1.3 site3 www.site3

/etc/nginx/sites-available/

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