Answer the question
In order to leave comments, you need to log in
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;
}
}
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;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question