lighttpd forum lighty > Perl Under FastCGI Troubleshooting

Posted by cryogen (Guest)
on 21.03.2008 04:07
Greetings,

I've been running lighttpd in my lab for about eight months now, and it 
has been running very solidly and I'm very happy with it.  So far I've 
been able to solve all my configuration problems on my own, but this one 
has me stumped.  This might just be a stupid question, but if someone 
could point me in the right direction I'd appreciate it.

What I've been trying to do is run existing perl cgi scripts under the 
fastcgi module for performance reasons and simplicity.  I already have 
php working fine with fastcgi, and now I'd like to do the same with 
perl.  What I've been trying to do is run one of the dispatcher scripts 
posted on the wiki to handle the running of the cgi scripts.  As far as 
I can tell I have everything set up right, but every time I start lighty 
I get this rather cryptic error message:

2008-03-20 17:39:08: (mod_fastcgi.c.1043) the fastcgi-backend
/usr/bin/dispatch.fcgi failed to start:
2008-03-20 17:39:08: (mod_fastcgi.c.1047) child exited with status 9 
/usr/bin/dispatch.fcgi
2008-03-20 17:39:08: (mod_fastcgi.c.1050) If you're trying to run PHP as 
a FastCGI backend, make sure you're using the FastCGI-enabled version. 
You can find out if it is the right one by executing 'php -v' and it 
should display '(cgi-fcgi)' in the output, NOT '(cgi)' NOR '(cli)'. For 
more information, check 
http://trac.lighttpd.net/trac/wiki/Docs%3AModFastCGI#preparing-php-as-a-fastcgi-programIf 
this is PHP on Gentoo, add 'fastcgi' to the USE flags.
2008-03-20 17:39:08: (mod_fastcgi.c.1354) [ERROR]: spawning fcgi failed.
2008-03-20 17:39:08: (server.c.892) Configuration of plugins failed. 
Going down.

I edited /etc/lighttpd/conf-available/10-fastcgi.conf to look like this:

fastcgi.server    = ( ".php" =>
	((
             <php settings skipped>
	)),
        ".cgi" =>
        ((
                "fastcgi.debug" => 1,
                "bin-path"      => "/usr/bin/dispatch.fcgi",
                "socket"        => "/tmp/lighttpd.perl.fcgi",
                "check-local"   => "disable",
                "min-procs"     => 1,
                "max-procs"     => 5,
                "idle-timeout"  => 20
        ))
)

The script (/usr/bin/dispatch.fcgi) I'm using is straight out of the 
wiki:

#!/usr/bin/perl -w
use strict;
use warnings;
use My::App;
use CGI::Fast();

while (my $q = new CGI::Fast){
    my $webapp = My::App->new( QUERY => $q );
    $webapp->run();
}

The CGI::Fast perl module is installed, at least I installed a perl 
module through my package manager that purported to be the fastcgi 
module.  The script permissions are 755.

So again, with the above settings and script lighty absolutely refuses 
to start and returns just the above cryptic error messages even with the 
fcgi debug mode on.

So, at the risk of asking stupid questions and having exhausting google, 
the wiki and my brain, I was hoping someone would be so kind as to give 
me some pointers as to what to do?

-- cryogen
Posted by nebulous (Guest)
on 29.04.2008 20:53
cryogen wrote:
> Greetings,
> 
> I've been running lighttpd in my lab for about eight months now, and it 
> has been running very solidly and I'm very happy with it.  So far I've 
> been able to solve all my configuration problems on my own, but this one 
> has me stumped.  This might just be a stupid question, but if someone 
> could point me in the right direction I'd appreciate it.
> 

I had similar trouble. Turned out the user the webserver was running as 
didn't have Read and eXecute permissions to the directory tree of my 
app.


nebulous -- http://www.sweetbeard.com/
Posted by Kai Krakow (Guest)
on 01.05.2008 11:41
nebulous wrote:
> I had similar trouble. Turned out the user the webserver was running as 
> didn't have Read and eXecute permissions to the directory tree of my 
> app.

If one is using pax/grsec, it may be essential to make the directories 
and the contained files owned by root and only writeable by root. Since 
this is an not so practical solution, you could try to directly set the 
interpreter instead of directly starting the script and let the OS 
figure out the interpreter:

"bin-path" => "/usr/bin/perl /usr/bin/dispatch.fcgi"

This circumvents the pax/grsec restriction since perl is only writeable 
by root and the binary is thus trusted. I've used something similar to 
get around pax/grsec restriction with the ruby on rails dispatcher.