我一直在使用 Apache CGI,并尝试在请求特定文件扩展名时运行 CGI 脚本。
我的 apache2.conf 中有以下内容:
AddHandler handle .html
Action handle /use/lib/cgi-bin/test.pl virtual
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory /usr/lib/cgi-bin>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
因此,当我尝试从 DocumentRoot 目录请求 html 页面 Hello.html 时,我收到一条错误消息,指出无法找到组合 CGI 脚本和请求文件的位置的路径:
Not Found
The requested URL /usr/lib/cgi-bin/test.pl/hello.html was not found on this server. Apache/2.2.22 (Ubuntu) Server at ryan-virtualbox Port 80Not Found
为什么我的 CGI 脚本无法运行,为什么此组合路径显示为“未找到”?
提前致谢。
最佳答案
根据mod_actions documentation ,cgi-script 是资源的 URL 路径。 所以我想你的 Action 指令应该重写:
Action handle /cgi-bin/test.pl virtual
关于Apache:操作指令未激活 CGI 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23052507/