【问题标题】:xampp 1.8.1 perl not working and throwing error 500xampp 1.8.1 perl 不工作并抛出错误 500
【发布时间】:2013-03-20 15:08:56
【问题描述】:

我在 Windows 7 上使用 xampp 1.8.1 并希望将其用于 perl,但是当我执行最简单的 hello world perl 脚本时,它给我一个错误 500。有人知道我做错了什么吗?这是我的“hello world”脚本:

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

提前致谢,

【问题讨论】:

  • 您的目录和该文件是否具有所有正确的文件模式?您的 URL 中的该文件的路径是否正确?可能需要更多信息才能有所帮助...
  • [2013 年 3 月 20 日星期三 16:17:22.205165] [win32:error] [pid 5420:tid 1656] [client ::1:52122] AH02102: C:/xampp/htdocs/test. pl 不可执行;确保解释的脚本有“#!”或者 ”'!”第一行 [Wed Mar 20 16:17:22.205165 2013] [cgi:error] [pid 5420:tid 1656] (9)Bad file descriptor: [client ::1:52122] AH01222: don't know how to spawn child进程:C:/xampp/htdocs/test.pl
  • 这是我的 apache 服务器上的 error.log 文件所说的
  • 嗯,C:/... 表示 windows,但您的 #!/usr/bin/perl 表示 unix... 它是哪个?
  • 我在 windows 上的 xampp apache 服务器上运行它

标签: perl xampp mod-perl httpexception


【解决方案1】:

将 shebang 行更改为实际指向您的 Perl 路径,例如:

#!c:/Strawberry/perl/bin/perl.exe

必要时可以引用:

#!"c:/Program Files/Perl/perl.exe"

请注意,在 Perl 中,即使在 Windows 上,您也始终可以对目录使用正斜杠(这是首选,因为它可以避免混乱的转义问题)。

在 Windows 上,shebang 行中的路径通常不用于执行。因此,为了与 Linux 兼容,通常使用#!/usr/bin/perl。但是,Apache确实使用了这个路径,所以需要进行相应的设置。

【讨论】:

    【解决方案2】:

    正确的代码是:

    #!C:\xampp\perl\bin\perl.exe
    
    # The above line is perl execution path in xampp
    
    # The below line tells the browser, that this script will send html content.
    # If you miss this line then it will show "malformed header from script" error.
    print "Content-ype: text/html\n\n";
    print "Hello world."
    

    在 xampp 中,perl 的执行路径是 C:\xampp\perl\bin\perl.exe 此外,您可以保存扩展名为 .pl、.pm、.cgi 的 perl 文件。但是对于浏览器使用,我更喜欢 .cgi 扩展名。

    我想这会对你有所帮助。

    【讨论】:

      猜你喜欢
      • 2013-10-18
      • 2014-10-02
      • 2016-12-10
      • 2011-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-23
      • 2015-10-11
      相关资源
      最近更新 更多