【发布时间】:2014-10-15 21:43:43
【问题描述】:
我正在尝试构建一个在线“实时聊天”服务,出于多种原因,我发现 FastCGI 适合该服务(根据其文档),但我似乎无法让它运行。
我正在使用安装了 mod_fcgid 的 Apache 2.2 共享主机。 我的 .htaccess 文件添加了以下行:
AddHandler fcgid-script .fcgi
我的perl测试脚本名为fcgitest.fcgi如下:
#!/usr/bin/perl
# fcgitest.fcgi
use diagnostics;
use warnings;
use strict;
use CGI;
use CGI::Carp 'fatalsToBrowser'; # tester only!
use FCGI;
my %env; my $in = new IO::Handle; my $out = new IO::Handle; my $err = new IO::Handle;
my $request=FCGI::Request($in, $out, $err, \%env);
if($request->IsFastCGI()==0) {
print "Content-Type: text/plain\n\n"; binmode STDOUT; print "ERR"; exit 0;
}
my $tm=time();
while($request->Accept() >= 0) {
my $env=$request->GetEnvironment();
print "Content-Type: text/plain\n\n"; binmode STDOUT;
print time()." ".$env;
if(time()>($tm+60)) { $request->Finish(); exit 0; }
}
print "Content-Type: text/plain\n\n"; binmode STDOUT; print "---"; exit 0;
当我从我的一个页面中调用此脚本时,我收到内部服务器错误,代码 500,在服务器日志文件中没有解释和错误日志。
- 我试图隐藏所有代码,只留下打印语句,问题依旧。
- 我尝试将文件移动到 fcgi-bin 目录,但问题仍然存在。
- 我已检查 perl 模块是否安装良好。
我不知道是什么导致了这个错误,因为我的主机供应商说服务器已经为 FCGI 配置好了......
【问题讨论】:
-
当您从命令行以与 apache 服务器相同的用户运行“perl -c fcgitest.fcgi”时会发生什么?
-
我没有 shell 访问权限...
-
你是如何部署自己的 fastcgi 处理程序的?
-
你为什么要把stdout放到binmode来发送text/plain?
标签: linux apache perl .htaccess