尝试使用 fast-cgi 和 lighttpd 运行 perl 脚本,但文件只是下载
问题是我的 .pl 脚本被下载为空白文件而不是被执行。
我读到: http://redmine.lighttpd.net/wiki/lighttpd/ApplicationsUsingLighttpd
我的dispatch.fcgi如下:(它位于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});
}
}
}
这是我的lighttpd配置文件中的代码:
".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
))
我必须安装CGI.pm和嵌入的cpan模块。 现在我的服务器日志中没有收到任何错误,但正如我所说,脚本只是下载。
谢谢你的帮助!
The problem is my .pl script is downloaded as a blank 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 lighttpd 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
谢谢你!
作品! 但是,我想知道为什么我需要打印标头才能使其与 fastcgi 和 lighttpd 一起使用。 我有一个别人写的大脚本,可以在我的 apache 和常规 cgi 服务器上运行。 我想我必须修改它才能在我的新服务器上工作。
问题是我认为打印标题可能会弄乱脚本,因为它会执行类似打印执行的 html 之类的操作。
再次感谢
Thank you!
works! But, I am wondering why I need to print the headers to get it to work with fastcgi and lighttpd. I have a large script someone else wrote that works on my apache and regular cgi server. I guess I have to modify it to work on my new server.
The problem is I think printing the header might mess up the script because it does something like printing html that gets executed.
Thanks again
让 carp 写入文件并查找问题。
Have carp write to a file and look there for problems.
确保为扩展设置静态排除。 像...
static-file.exclude-extensions = ( ".php", ".pl" )
或者它只会像其他文件一样下载该文件。
Make sure static exclude is set for the extensions. Something like...
static-file.exclude-extensions = ( ".php", ".pl" )
Or it will just download the file like any other.
您似乎没有发送正确的标头。 使用 CGI 模块中的“header”函数来发出标头
然后你就可以开始了。
有关更多信息,请查看标头文档:
http:// /cpansearch.perl.org/src/LDS/CGI.pm-3.43/cgi_docs.html#header
It appears that you are not sending the correct headers. Use the "header" function in the CGI module to emit the headers
Then you should be good to go.
For more information check out the header documentation:
http://cpansearch.perl.org/src/LDS/CGI.pm-3.43/cgi_docs.html#header