为多个域设置Nginx
我看过一些以前贴出的类似于我的问题,但没有一个与我的问题相关 在我的Nginx配置中,我进行了以下设置:为多个域设置Nginx,nginx,Nginx,我看过一些以前贴出的类似于我的问题,但没有一个与我的问题相关 在我的Nginx配置中,我进行了以下设置: server { listen 80; server_name (www.)?domain1.com; root /etc/nginx/www/domain1.com; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)
server {
listen 80;
server_name (www.)?domain1.com;
root /etc/nginx/www/domain1.com;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
server {
listen 80;
server_name (www.)?domain2.com;
root /etc/nginx/www/domain2.com;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
但出于某种原因,这两个域似乎都指向/etc/nginx/www/domain2.com。我可能做错了什么?您在
server\u name
指令中有错误
Regexp服务器名称的前缀必须为~
但使用它会更好
server_name domain1.com www.domain1.com;
您在进行更改后是否重新加载了服务?@shtuff。如果我重新加载了服务,似乎没有什么区别。您在
服务器名称
指令中出错。Regexp服务器名称的前缀必须为~
。但最好使用server\u name domain1.com www.domain1.com代码>@AlexeyTen太棒了。你能给我一个答案,这样我就可以把它选为最好的吗?顺便说一句,如果你有这样的try\u文件
指令,fastcgi\u split\u path\u info
是没有用的。