Trying to run perl scripts with fast-cgi and lighttpd, but the files just load

The problem is that my .pl script is loading as an empty file and not executed.

I read: http://redmine.lighttpd.net/wiki/lighttpd/ApplicationsUsingLighttpd

My dispatch.fcgi is the following: (it is in usr / bin /

#!perl
#!/usr/bin/perl
use strict;
use CGI::Fast;
use Embed::Persistent; {
my $p = Embed::Persistent->new();
while (new CGI::Fast) {
my $filename = $ENV{SCRIPT_FILENAME};
my $package = $p->valid_package_name($filename);
my $mtime;
if ($p->cached($filename, $package, \$mtime)) {
eval {$package->handler;};
}
else {
$p->eval_file($ENV{SCRIPT_FILENAME});
}
}
}

This is my code in the lighttpd configuration file:

".pl" =>
((
"fastcgi.debug" => 1,
"bin-path" => "/usr/bin/dispatch.fcgi",
"socket" => "/tmp/fcgi.socket",
"check-local" => "disable",
"min-procs" => 1,
"max-procs" => 5,
"idle-timeout" => 20
))

I had to install CGI.pm and the cpan built-in module. Now I have no errors in my server, but, as I said, the script just loads.

Thanks for any help!

+3
source share
4 answers

, . "header" CGI,

$cgi = new CGI;
$cgi->header();

.

:

http://cpansearch.perl.org/src/LDS/CGI.pm-3.43/cgi_docs.html#header

+1

.

BEGIN {
use CGI::Carp qw/carpout/;
open LOG, ">>", "carp.log" or die("Cannot open file: $!\n");
carpout(LOG);
}
+1

, static exclude. - ...

static-file.exclude-extensions = ( ".php", ".pl" )

, .

+1

!

#!/usr/bin/perl -w
use strict;
my $cgi = new CGI;
print $cgi->header();
print 'Hello world.';

! , , fastcgi lighttpd. script - , Apache cgi. , .

The problem is that heading printing can ruin the script, because it does something like html printing that is being executed.

Thanks again

0
source

Source: https://habr.com/ru/post/1708300/


All Articles