8

I just installed fcgiwrap and spawn-fcgi to be able to use perl scripts in nginx. I added something like this in my site config:

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

It works but browser shows the following message if there is an error in perl code:

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

And I am not able to find perl errors in the nginx logs. "perl -c" on the command line helps if there are perl compilation errors but it does not help me solve runtime errors.

How can I tell perl or fcgiwrap to save errors in nginx error log or some other log file?

toktok
  • 279
  • 1
  • 5
  • 13

2 Answers2

1

There are a number of nice tools to capture run-time errors of Perl web apps and show them to you. These debugging tools can be disabled in production through various means. They basically "eval" the bulk of the code, allow them to handle most errors. Some examples:

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49
0

Perhaps it is becourse your nginx have no permission to access the file "CGI.pm".

Look this:

[root@mars 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.

[root@mars 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
[root@mars www]#
1.618
  • 847
  • 2
  • 11
  • 19