A
A
AleDv2018-06-29 21:37:21
Nginx
AleDv, 2018-06-29 21:37:21

How to make virtual hosts work in nginx?

Hello. There is a VDS on which one virtual host is planned so far. Accordingly, sites-available contains two files: default and site.ru. Here are their configs:
Default:

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

        root /var/www/html;

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

        #server_name _;

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

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

        location ~ /\.ht {
               deny all;
        }
}

Site.ru
server {

  listen 80;
  listen [::]:80;
  server_name site.ru;
  
  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;	

  root /var/www/html/site.ru/public;

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

  
  location ~ \.php$ {	
    include fastcgi_params;
    fastcgi_pass unix:/run/php/php7.1-fpm.sock;
    try_files $uri =404;
  }

  location ~ /\.ht {
    deny all;
  }
}

When requested in the site.ru browser, nginx works with default settings. How to make the server "eat the correct settings", i.e. site.ru config - I don't know, apparently I screwed up somewhere.
Tell me what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2018-06-29
@ky0

Are the links from availableto enableddone?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question