2012-03-30 91 views
7

我刚刚安装了fcgiwrap和spawn-fcgi以便能够在nginx中使用perl脚本。我说这样的事情在我的网站的配置:如何获得nginx错误日志中的perl脚本错误(Nginx与FCGIwrap)

location ~ \.pl$ { 
    gzip off; 
    fastcgi_pass unix:/var/run/fcgiwrap.socket; 
    include fastcgi_params; 
    fastcgi_index index.pl; 
} 

它的工作原理,但浏览器会显示以下信息,如果有在Perl代码中的错误:

An error occurred while reading CGI reply (no response received) 

而且我无法找到perl的错误在nginx日志中。命令行上的“perl -c”有助于解决perl编译错误,但它不能帮助我解决运行时错误。

如何告诉perl或fcgiwrap将错误保存在nginx错误日志或其他一些日志文件中?

回答

1

有很多好的工具可以捕获Perl Web应用程序的运行时错误并显示给您。这些调试工具可以通过各种方式在生产中禁用。他们基本上“评估”了大部分代码,允许他们处理大多数错误。一些例子:

0

也许是因为你的nginx没有权限访问文件“CGI.pm”。

看看这个:

[[email protected] www]# sudo -u nginx ./foo.cgi 
Can't locate CGI.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./foo.cgi line 2. 
BEGIN failed--compilation aborted at ./foo.cgi line 2. 

[[email protected] www]# ./foo.cgi 
Status: -charset 
Set-Cookie: utf-8 
Date: Fri, 29 Sep 2017 02:49:38 GMT 
Content-Type: text/html; charset=ISO-8859-1 

本文最后更新时间:20170929 10:35:29 
[[email protected] www]#