【问题标题】:how to set up a VirtualHost for cgi-bin execution?如何为 cgi-bin 执行设置 VirtualHost?
【发布时间】:2023-11-29 10:52:01
【问题描述】:

我在 httpd 的配置文件的 VirtualHost 选项卡中创建了以下指令:

      ScriptAlias /cgi-bin/ "/usr/myhome/cgi"
      <Directory "/usr/myhome/cgi/">
       AllowOverride None
       Options None
       Order allow,deny
       Allow from all
      </Directory>

我还创建了 shell 脚本:

      #! /bin/sh

     echo "Content-type: text/html"
     echo
     echo
     echo Hello

在 /var/myhome/cgi 目录中。

不过,我还是跑不了http://server.com/cgi-bin/1.sh

我收到“内部服务器错误”。

httpd 日志文件显示:

           [Mon Jul 28 21:18:19 2014] [error] [client 128.237.220.69] /bin/sh: /usr/myhome/cgi/1.sh: Permission denied
           [Mon Jul 28 21:18:19 2014] [error] [client 128.237.220.69] Premature end of script headers: 1.sh

即使我将目录的权限更改为全球可读和可执行,并且脚本也使用 chmod 0777(只是为了确保它可以做任何事情)。

任何想法如何调试权限被拒绝错误源是什么?

【问题讨论】:

    标签: apache cgi


    【解决方案1】:

    你至少需要Options +ExecCGIAddHandler cgi-script

    http://httpd.apache.org/docs/2.2/howto/cgi.html

    编辑: 哎呀,我完全想念你在使用ScriptAlias,但我不确定你的文件路径should be quoted

    【讨论】: