Lighttpd и cgi скрипты (мониторинга apcupsd)
Добавлено: 2009-11-26 12:10:03
Как заставить lighttpd выполнять cgi скрипты?
Lighttpd настроен с fastcgi
Lighttpd настроен с fastcgi
Если проблема не решается сама, значит она неразрешима
https://forum.lissyara.su/
Код: Выделить всё
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
".php" => "/usr/local/bin/php-cgi" )
Код: Выделить всё
server.modules = (
# "mod_fastcgi",
"mod_cgi",
)
static-file.exclude-extensions = ( ".cgi", ".fcgi", ".php", ".rb", "~", ".inc", ".pl", ".yml" )
#fastcgi.server = ( ".php" =>
# ( "localhost" =>
# (
# "socket" => "/tmp/php-fastcgi.socket",
# "bin-path" => "/usr/local/bin/php-cgi"
# )
# )
# )
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
".php" => "/usr/local/bin/php-cgi"
)
Код: Выделить всё
/usr/local/www/apcupsd -> /usr/local/etc/apcupsd
Код: Выделить всё
alias.url = ( "/apcupsd" => "/usr/local/etc/apcupsd" )
Покажи лог lighttpd errorOSBoy писал(а):В итоге при попытке открыть в браузере http://your-site/cgi-bin/multimon.cgi во всех случаях получаю "500 - Internal Server Error"! Кто-нибудь подскажет, как это победить?
Вот, но это выводится, пока работает phpsysinfo. При обращении к cgi скриптам apcupsd в lighttpd.error.log ничего не пишется.tail -f /var/log/lighttpd.error.log
2009-11-27 17:26:22: (mod_cgi.c.1279) cleaning up CGI: process died with signal 11
2009-11-27 17:26:22: (mod_cgi.c.1279) cleaning up CGI: process died with signal 11
2009-11-27 17:26:23: (mod_cgi.c.1279) cleaning up CGI: process died with signal 11
2009-11-27 17:26:24: (mod_cgi.c.587) cgi died, pid: 84378
2009-11-27 17:26:24: (mod_cgi.c.587) cgi died, pid: 84379
2009-11-27 17:26:24: (mod_cgi.c.587) cgi died, pid: 84380
2009-11-27 17:26:25: (mod_cgi.c.587) cgi died, pid: 84381
2009-11-27 17:26:25: (mod_cgi.c.587) cgi died, pid: 84382
2009-11-27 17:26:25: (mod_cgi.c.587) cgi died, pid: 84383
2009-11-27 17:26:25: (mod_cgi.c.587) cgi died, pid: 84384
2009-11-27 17:26:27: (mod_cgi.c.587) cgi died, pid: 84385
Код: Выделить всё
server.modules = (
....
"mod_fastcgi",
# "mod_cgi",
....
)
static-file.exclude-extensions = ( ".cgi", ".fcgi", ".php", ".rb", "~", ".inc", ".pl", ".yml" )
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php-fastcgi.socket",
"bin-path" => "/usr/local/bin/php-cgi"
)
),
".cgi" =>
( "localhost" =>
(
"host" => "127.0.0.1",
"port" => 9000
)
)
)
#cgi.assign = ( ".pl" => "/usr/bin/perl",
# ".cgi" => "/usr/bin/perl",
# ".php" => "/usr/local/bin/php-cgi"
# )
Код: Выделить всё
2009-11-27 20:16:58: (mod_fastcgi.c.1742) connect failed: Connection refused on tcp:127.0.0.1:9000
2009-11-27 20:16:58: (mod_fastcgi.c.2943) backend died; we'll disable it for 5 seconds and send the request to another backend instead: reconnects: 0 load: 1
2009-11-27 20:17:04: (mod_fastcgi.c.2756) fcgi-server re-enabled: tcp:127.0.0.1:9000
Код: Выделить всё
#!/usr/bin/perl -w
use strict;
print "Content-type: text/html\n\n";
print "oki";
И??thefree писал(а):запустите плизКод: Выделить всё
#!/usr/bin/perl -w use strict; print "Content-type: text/html\n\n"; print "oki";
Код: Выделить всё
tail -f /var/log/lighttpd.error.log
2009-12-06 16:59:53: (mod_fastcgi.c.1742) connect failed: Connection refused on tcp:127.0.0.1:9000
2009-12-06 16:59:53: (mod_fastcgi.c.2943) backend died; we'll disable it for 5 seconds and send the request to another backend instead: reconnects: 0 load: 1
2009-12-06 16:59:59: (mod_fastcgi.c.2756) fcgi-server re-enabled: tcp:127.0.0.1:9000
Код: Выделить всё
fastcgi.server = (
".pl" =>
( "localhost" =>
(
"socket" => "/tmp/perl-fastcgi.socket",
"bin-path" => "/usr/bin/perl"
)
)
)
Код: Выделить всё
#!/usr/bin/perl
use strict;
use FCGI;
while( FCGI::accept() >= 0 )
{
print( "Content-Type: text/plain", "\n\n" );
print( "Hello World in Perl", "\n" );
}
Вот что получилось:thefree писал(а):начнем с первого вопроса FCGI модуль для perl стоит?
Код: Выделить всё
2009-12-09 12:14:22: (log.c.172) server started
2009-12-09 12:14:22: (mod_fastcgi.c.1087) the fastcgi-backend /usr/bin/perl failed to start:
2009-12-09 12:14:22: (mod_fastcgi.c.1091) child exited with status 0 /usr/bin/perl
2009-12-09 12:14:22: (mod_fastcgi.c.1094) If you're trying to run your app as a FastCGI backend, make sure you're using the FastCGI-enabled version.
If this is PHP on Gentoo, add 'fastcgi' to the USE flags.
2009-12-09 12:14:22: (mod_fastcgi.c.1398) [ERROR]: spawning fcgi failed.
2009-12-09 12:14:22: (server.c.928) Configuration of plugins failed. Going down.
Код: Выделить всё
Options for perl 5.8.9_3
[ ] DEBUGGING Build with debugging support
[ ] GDBM Build GDBM_File extension
[X] PERL_MALLOC Use Perl malloc
[X] PERL_64BITINT Use 64 bit integers (on i386)
[ ] THREADS Build threaded perl
[ ] SUIDPERL Build set-user-id suidperl binary
[ ] SITECUSTOMIZE Run-time customization of @INC
[X] USE_PERL Rewrite links in /usr/bin
Собрал - эффекта нет, в логе тоже самое. И вообще, причём тут spawn-fcgi ?thefree писал(а):lighttpd вы должны были собрать с поддержкой spawn-fcgi (/usr/ports/www/spawn-fcgi)
Код: Выделить всё
fastcgi.server = ( ".fpl" =>
( "localhost" =>
(
"host" => "localhost",
"port" => 9090
)
)
)
Код: Выделить всё
#!/usr/bin/perl -w
use strict;
use FCGI;
use CGI;
my $socket = FCGI::OpenSocket(":9090", 5);
my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, $socket);
my $c = 0;
while($request->Accept() >= 0) {
$c++;
print "Content-type: text/plain\n\n";
print "Hello World in Perl<br>\n";
print "$_ = $ENV{$_}<br>\n" foreach sort keys %ENV;
print "<hr>\n";
my $query = CGI->new();
print "$_ = ", $query->param($_), "<br>\n" foreach sort $query->param();
}
FCGI::CloseSocket($socket);
Код: Выделить всё
fastcgi.debug = "1"
fastcgi.server = ( ".pl" =>
( "localhost" =>
(
"host" => "127.0.0.1",
"port" => 9000
)
)
)
Код: Выделить всё
2009-12-10 18:55:17: (mod_fastcgi.c.1734) connect failed: Connection refused on tcp:127.0.0.1:9000
2009-12-10 18:55:17: (mod_fastcgi.c.455) backend disabled for 1 seconds
2009-12-10 18:55:17: (mod_fastcgi.c.3024) backend died; we'll disable it for 1 seconds and send the request to another backend instead: reconnects: 0 load: 1
2009-12-10 18:55:19: (mod_fastcgi.c.2851) fcgi-server re-enabled: tcp:127.0.0.1:9000
Код: Выделить всё
#### CGI module
cgi.assign = ( ".pl" => "",
".cgi" => "",
"multimon.cgi" => "" )
Код: Выделить всё
svr# /usr/bin/perl /usr/local/www/apc/multimon.cgi
Unrecognized character \x7F in column 1 at /usr/local/www/apc/multimon.cgi line 1.
svr#
Код: Выделить всё
alias.url += ( "/apcupsd/" => "/usr/local/etc/apcupsd/cgi/" )
$HTTP["url"] =~ "^/apcupsd/" {
cgi.assign = ( "" => "" )
}