2012-03-30 66 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]#