在下面的几行中,我可能有一个特定于站点的配置文件,其中包含该站点独有的其他fastcgi_params。如果这个文件存在,我想加载它。
server {
listen 80 default;
server_name _;
root /path/www/$host;
# Pass PHP scripts to php-fastcgi listening on port 9000
location ~ \.php {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
if (-f /path/www/$host/nginx.conf) {
include /path/www/$host/nginx.conf;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用,我得到的错误是:
nginx: [emerg] "include" 指令在这里是不允许的......
我认为与其单独检查,不如让include 来检查我。
server {
listen 80 default;
server_name _;
root /path/www/$host;
# Pass PHP scripts to php-fastcgi listening on port 9000
location ~ \.php {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000; …Run Code Online (Sandbox Code Playgroud)