如何在Apache 2上忽略Windows上的Perl shebang?

Nic*_*ton 11 windows perl apache2 shebang activeperl

我在Windows机器上设置了一个本地Perl Web环境.我正在处理的应用程序最初来自Linux服务器,因此源.pl文件的shebang 如下所示:

#!/usr/bin/perl
Run Code Online (Sandbox Code Playgroud)

这会导致我的Windows开发机器出现以下错误:

(OS 2)The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)

是否可以更改我的Apache 2 conf以便在我的Windows机器上忽略shebang?当然我可以设置shebang #!c:\perl\bin\perl.exe,这很明显; 但问题是部署更新的文件.显然,在每次部署时更改这一点会非常不方便.我在Windows 7上使用ActivePerl.

更新:

我应该提到我需要保留shebang,以便脚本可以在我们的共享主机Linux生产服务器上运行.如果我没有这个约束而且我不必使用shebang,那么显而易见的答案就是不使用它.

Sin*_*nür 12

#!/usr/bin/perl在我的脚本中使用并在Windows上配置Apache以忽略shebang行.加

 ScriptInterpreterSource Registry-Strict
Run Code Online (Sandbox Code Playgroud)

httpd.conf并设置为在解释Windows注册表键的Apache文档.

这是我导出密钥时得到的结果:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI\Command]
@="c:\\opt\\perl\\bin\\perl.exe"

我一直在我的Windows笔记本电脑上使用Apache和ActiveState Perl的这个设置,以及我的服务器上的ArchLinux附带的Apache和Perl发行版.

Apache文档(我上面链接的)说明:

在Apache 2.0中新增的Registry-Strict选项与Registry完全相同,但仅使用子项Shell\ExecCGI\Command.ExecCGI键不是常见的一种.它必须在Windows注册表中手动配置,因此可以防止系统上的意外程序调用.(强调我的)