perl - 为什么我在 IIS 上使用 Perl CGI 程序时会出现 "Bad Gateway"错误?

标签 perl iis cgi

我试图在 Windows 7 上运行示例 Perl 脚本,并且我配置了 IIS 7 以允许 ActivePerl 运行,但我收到此错误:

HTTP Error 502.2 - Bad Gateway
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "Hello World. ".

Module  CgiModule
Notification    ExecuteRequestHandler
Handler Perl Script (PL)
Error Code  0x00000000
Requested URL   http://localhost:80/hello.pl
Physical Path   C:\inetpub\wwwroot\hello.pl
Logon Method    Anonymous
Logon User  Anonymous

and here is my Perl script:

#!/usr/bin/perl
print "Hello World.\n";

最佳答案

从任何 CGI 程序返回的第一个输出应该是标题。

尝试

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "Hello World.\n";

关于perl - 为什么我在 IIS 上使用 Perl CGI 程序时会出现 "Bad Gateway"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2741268/

相关文章:

regex - 从 perl regexp 中清除只读变量

regex - 使用 perl 插入可能缺失的行

perl - 捕获稀疏矩阵的非零元素、计数和索引

iis - IIS 上的 .htaccess 或 .htpasswd 等效项?

iis - Web 应用程序是如何启动的?入口点在哪里(如果有的话)?

C CGI程序: how to print dynamically?

perl - mod_perl 跨子进程共享变量

python - 在 IIS 上设置 Django

php - 使用 PHP 屏蔽图像生成 CGI 脚本的 URL

perl - 如何在CGI中编码base64 md5?