[英]How do you use the Apache “ScriptInterpreterSource Registry-Strict” directive?
我在 Windows 上运行 Apache Web 服务器以便处理一些 Perl CGI 脚本。 在生产中,这些脚本在 linux 机器上运行,在源代码存储库中,它们都有像: #!/usr/bin/perl
的 shebangs,但在我的 Windows 机器上,shebangs 将是#!c:\\perl\\bin\\perl.exe
,所以我与源代码库有冲突。
输入 Apache ScriptInterpreterSource指令。
我一直在努力使其工作,基于我可以谷歌的内容。 但到目前为止还没有运气。 我有:
将这些东西添加到适当的指令 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
现在,我知道 CGI 可以在这台服务器上工作,只要它们有正确的 shebang。
但是当我尝试在没有shebang的情况下访问CGI时,apache日志会吐出:
找不到“.cgi”类型文件的 Exec CGI 动词
任何想法、见解,甚至疯狂的猜测都将不胜感激。
谢谢。
听起来 ScriptInterpreterSource 行被忽略了。 如果设置为 Registry 或 Registry-Strict,则应忽略 shebang 行并仅使用注册表。
此外, Apache 2.2 文档的注册表项位置略有不同:
HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command\(Default) => C:\Perl\bin\perl.exe -wT
这也适用于 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
与其在单独的 CGI 进程中运行 perl 代码,不如考虑使用mod_perl (参见http://perl.apache.org )。
Mod_perl 效率更高,因为 Perl 代码只加载和解析一次,然后直接在 Apache 进程中运行,无需启动或与其他进程通信。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.