有时在configurationnginx和php-fpm时,我得到消息“找不到文件”。 我知道这是由于错误的参数SCRIPT_FILENAME,例如:
fastcgi_param SCRIPT_FILENAME /some/path$fastcgi_script_name;
我不知道是否有一种方法来获得确切的完整path的文件,这是不能find的php-fpm?
我的php5-fpm.log没有任何内容,但是:
[06-Jan-2014 11:14:33] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful [06-Jan-2014 11:27:01] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful
我已经尝试将php-fpm.conf中的log_level选项更改为error和debug ,但结果保持不变
PS这一行:
add_header X-My-Header /some/path$fastcgi_script_name;
不会这样做,因为add_header只能用于成功的响应,正如我在这里阅读的
有nginx模块 ,即使有失败响应也可以设置头文件,但我认为它应该是一个更简单的方法来获取文件path。
谢谢。
解决scheme将是由nginx使用log_formatlogging需要的variables。
在最简单的情况下,它可能看起来像这样(将此代码粘贴到http上下文中):
log_format mylog '$fastcgi_script_name'; access_log /var/log/nginx/access.log mylog;
然后你可以在访问日志文件中看到结果(在我的例子中是/var/log/nginx/access.log )。
另一个解决scheme是用HttpHeadersMoreModule编译nginx。 这个模块允许您比使用nginx默认的add_header指令更灵活地操作http头。 所以要查看$fastcgi_script_name值,你可以这样写:
location ~ \.php$ { more_set_headers "x-debug-header: $fastcgi_script_name"; fastcgi_pass 127.0.0.1:9000; ... }
然后,您可以在“networking”标签(或其他浏览器中的类似工具)中的Google Chrome开发工具中查看标题。
PS与HttpHeadersMoreModule你也可以重写一个Server头,如果你当然需要:
more_set_headers "Server: my_server";
祝你好运!