我安装nginx-1.6.2,2
了FreeBSD-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