我正在将服务器从Apache + mod_cgi迁移到nginx + fastcgiwrap,由于某种原因,应用程序cerr没有出现在nginx错误中。
nginx设置:
server {
error_log /var/log/nginx/test-error.log;
# ...
location ~ \.cgi$ {
# ...
fastcgi_intercept_errors on;
}
}
错误日志权限:
~# ls -lA /var/log/nginx/test-error.log
-rwxrwxrwx 1 www-data www-data 0 Jun 17 21:27 /var/log/nginx/test-error.log
fastcgi“-f”标志:
~# head -39 /etc/init.d/fcgiwrap | tail -1
DAEMON_OPTS="-f" # By default we redirect STDERR output from executed
申请本身:
#include <iostream>
int main( void ) {
std::cout << "Content-Type: text/html; charset=UTF-8\n\n";
std::cout << "Hello World.";
std::cerr << "Should appear on the nginx log..." << std::endl;
return 0;
}
应用程序运行完美,但没有快乐得到错误日志写,我错过了什么?