10

错误信息是:

command not in docroot (/home/site1/cgi-bin/test.pl).

在这里我发现了这个:

suexec 要求 CGI 脚本位于服务器的 DocumentRoot(而不是 VirtualHost DocumentRoot)下。但是,VirtualHost DocumentRoot 可以是指向出现在真实 DocumentRoot 下的目录的符号链接。

虚拟主机配置的一部分是:

[...]
DirectoryIndex index.html index.html index.php
DocumentRoot /home/site1/htdocs

SuexecUserGroup site1 site1

ScriptAlias /cgi-bin/ /home/site1/cgi-bin/
<Location /home/site1/cgi-bin>
           Options +ExecCGI
</Location>

<Directory /home/site1/>
Options -Includes -Indexes -FollowSymLinks +ExecCGI MultiViews
AddHandler cgi-script .cgi .pl
AllowOverride none
Order allow,deny
Allow from all
</Directory>
[...]

所以,我更喜欢在 cgi-bin 中有 Perl 脚本,但如果我不能解决这个问题,我可以将所有脚本移动到 htdocs。

4

3 回答 3

20

suEXEC有自己的docroot,完全独立于您在 Apache 配置中配置的任何内容。您可以suEXEC通过调用以下命令查看 docroot 是什么:

suexec -V

您可能需要为此扎根。在我的情况下,docroot 是/var/www. 你必须把你的脚本放在那里。没有办法改变这个保存重新编译suEXEC。不要尝试使用符号链接将您的脚本保留在外部/var/www(或您suEXEC配置的任何内容)。

编辑:正如@insaner 在评论中提到的,该命令可能是suexec或者正如我在至少一台服务器上看到的那样suexec2suEXEC正是 Apache 文档所称的模块/功能。

于 2013-09-30T16:21:39.000 回答
2

/etc/apache2/suexec/www-data如果您使用的是 package.json,则在前 2 行下面有一个配置apache2-suexec-custom

/var/www
public_html/cgi-bin

您需要用您的设置替换这些行。应该有 2 行。只给一行会出错。

我使用了类似下面的东西,

home
cgi-bin
于 2020-08-03T05:19:25.623 回答
-4

将 DocumentRoot更改/home/site1/htdocs为 DocumentRoot/home/site1/

于 2013-09-26T13:09:33.590 回答