Answer the question
In order to leave comments, you need to log in
How to properly configure nginx for multiple sites and subdomains?
There are several sites: site.ru, site1.ru, site2.ru and subdomains: sub.site.ru, admin.sub.ru, mail.sub.ru, etc.
At the moment:
In the folder /sites-available/:
File site.ru :
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name site.ru www.site.ru;
root "/var/www/site.ru/";
include sites-available/common.conf;
}
server {
server_name site.ru www.site.ru;
root "/var/www/site.ru/";
include sites-available/common.conf;
}
server {
server_name blog.site.ru;
root "/var/www/site.ru/blog/";
include sites-available/common.conf;
}
index index.php index.html index.htm;
###
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#Error log:
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
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