您如何使用 Apache 的“ScriptInterpreterSource Registry-Strict”指令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/379930/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do you use the Apache "ScriptInterpreterSource Registry-Strict" directive?
提问by user46775
i run Apache web server on windows in order to work on some Perl CGI scripts. in production these scripts run on a linux box, and in the source code repository they all have shebangs like: #!/usr/bin/perl, but on my windows machine the shebangs would be #!c:\perl\bin\perl.exe, so i have a conflict with the source code base.
我在 Windows 上运行 Apache Web 服务器以便处理一些 Perl CGI 脚本。在生产中,这些脚本在 linux 机器上运行,在源代码存储库中,它们都有类似的 shebangs:,#!/usr/bin/perl但在我的 Windows 机器上,shebangs 会是#!c:\perl\bin\perl.exe,所以我与源代码库有冲突。
enter the Apache ScriptInterpreterSourcedirective.
输入 Apache ScriptInterpreterSource指令。
i've been trying to make it work, based on what i can google. but so far no luck. i have:
我一直在努力让它发挥作用,基于我可以谷歌搜索的内容。但到目前为止还没有运气。我有:
added these things to the appropriate directive AllowOverride None
Options Indexes FollowSymLinks ExecCGI Order allow,deny Allow from all ScriptInterpreterSource Registry-Strictadded: AddHandler cgi-script .cgi
edited my registry and added a new String to
将这些东西添加到适当的指令 AllowOverride None
Options Indexes FollowSymLinks ExecCGI Order allow,deny Allow from all ScriptInterpreterSource Registry-Strict添加:AddHandler cgi-script .cgi
编辑了我的注册表并添加了一个新字符串
HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command=C:\Perl\bin\perl.exe
HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command=C:\Perl\bin\perl.exe
now, i know that CGIs work on this server as long as they have the right shebang.
现在,我知道 CGI 可以在这台服务器上工作,只要它们有正确的 shebang。
but when i try to access a CGI without a shebang the apache log spits out:
但是当我尝试在没有 shebang 的情况下访问 CGI 时,apache 日志会吐出:
No Exec CGI Verb found for files of type '.cgi'
找不到“.cgi”类型文件的 Exec CGI 动词
any thoughts, insights, or even wild-ass guesses would be appreciated.
任何想法、见解,甚至疯狂的猜测都将不胜感激。
thanks.
谢谢。
回答by Powerlord
It sounds like the ScriptInterpreterSource line is being ignored. If it's set to Registry or Registry-Strict, it should ignore the shebang lines and use the registry only.
听起来 ScriptInterpreterSource 行被忽略了。如果设置为 Registry 或 Registry-Strict,则应忽略 shebang 行并仅使用注册表。
Also, the Apache 2.2 docshave a slightly different location for the registry key:
此外,Apache 2.2 文档的注册表项位置略有不同:
HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command\(Default) => C:\Perl\bin\perl.exe -wT
回答by Ken Washington
This works for Python scripts as well. I did the following to fix my Apache install to ignore the shebang requirement in my scripts. Without this the shebang is required in the current version of Apache 2.4 - or at least it was in mine.
这也适用于 Python 脚本。我做了以下修复我的 Apache 安装以忽略脚本中的 shebang 要求。如果没有这个,当前版本的 Apache 2.4 中需要 shebang - 或者至少在我的版本中是这样。
# tell apache to use registry - this requried a registry hack
# to the following:
# [HKEY_CLASSES_ROOT\.py\Shell\ExecCGI\Command] = "c:\python\python.exe"
ScriptInterpreterSource Registry-Strict
回答by haa
Instead of running your perl code in separate CGI processes, consider using mod_perl(See http://perl.apache.org).
与其在单独的 CGI 进程中运行 perl 代码,不如考虑使用mod_perl(参见http://perl.apache.org)。
Mod_perl is a lot more efficient, as the Perl code is loaded and parsed only once and then runs directly within the Apache processes with no need to start or communicate with other processes.
Mod_perl 效率更高,因为 Perl 代码只加载和解析一次,然后直接在 Apache 进程中运行,无需启动或与其他进程通信。

