Nginx 虚拟主机 服务器名,root

Nginx 虚拟主机 服务器名,root

我安装nginx-1.6.2,2FreeBSD-9.2-RELEASE-p5,这是我的配置:

# tail -2 nginx.conf
    include _includes/*.conf;
}
# cat _includes/XXX.conf 
server {
    server_name XXX;
    root    /home/user/XXX/;
    index   index.php;
    include _includes/_location-php.include;
}
# cat _includes/_location-php.include 
location ~ \.php$ {
    include fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_pass    unix:/var/run/php-fpm.sock;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# tail -1 /var/log/nginx-error.log 
2014/11/17 11:45:59 [error] 82950#0: *6 open() "/usr/local/www/nginx/admin.php" failed (2: No such file or directory), client: XX.XX.XX.XX, server: localhost, request: "GET /admin.php HTTP/1.1", host: "XXX"
# 

还有另一个root指向/usr/local/www/nginx另一个服务器块server_name localhost(默认配置 -http://pastebin.com/caRJM20f

为什么它要接管root我指定的那个server_name

答案1

您需要在文件的部分listen [IP:]80;内部添加。server_includes/XXX.conf

相关内容