Trying to run perl scripts with fast-cgi
Added by minustwo almost 16 years ago
Hello, I am fairly new to linux. I am setting up a centOS5 server with lighttpd, mysql, and php/perl through fast-cgi. I believe I have php working with fast-cgi, however, I'm confused with how to get my perl scripts to run. I am not sure what to put in the socket and bin-path for the perl scripts of my lighttpd.conf file.
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/var/run/lighttpd/php-fastcgi.socket",
"bin-path" => "/usr/bin/php-cgi"
)
),
".pl" =>
( "localhost" =>
(
"socket" => "????????",
"bin-path" => "?????"
)
)
)
Also, I can access my website by just typing in localhost into my browser. On my system, my root directory for the website is /srv/www/lighttpd/.
Do I put perl scripts in a directory behind my root html directory?:
/srv/www/cgi-bin
or do I put scripts in a cgi-bin directory in the root directory?:
/srv/www/lighttpd/cgi-bin
One final question, in my perl scripts, do I need to change the top line from:
#!/usr/bin/perl -w
Thanks to anyone who can help!
Replies (2)
RE: Trying to run perl scripts with fast-cgi - Added by minustwo almost 16 years ago
Maybe I am confused, but do people usually use fast cgi to run perl scripts, or do you just set something up like:
- CGI module. You can install Perl and assign .pl and .cgi scripts
- to /usr/bin/perl
$HTTP["url"] =~ "/cgi-bin/" {
cgi.assign = (
".sh" => "/bin/sh",
".cgi" => "/usr/bin/perl,
".pl" => "/usr/bin/perl
)
}
RE: Trying to run perl scripts with fast-cgi - Added by minustwo almost 16 years ago
Hello! I think I am close to getting it to work...I just need a little help.
The problem is my script is downloaded as a file instead of being executed.
I read: http://redmine.lighttpd.net/wiki/lighttpd/ApplicationsUsingLighttpd
My dispatch.fcgi is the following: (it is located 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 my config 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 module embed.
Now I do not get any errors in my server log, but as I said, the script just downloads.
Thanks for any help!