1

我一直在努力让它工作,但无论我做什么,我都无法在我的虚拟目录的 cgi-bin 中执行 .pl 文件。在过去的 4 个小时里,我一直在寻找解决方案,并尝试了我遇到的所有问题,但没有什么对我有用。Perl 文件在我的默认站点上运行得很好,但对我的虚拟主机来说却不是。我的 Apache2 配置中唯一修改过的文件是 /etc/apache2/sites-available/default 文件,目前如下(站点名除外):

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
   </Directory>

    <Directory /var/www/cgi-bin>
            Options +ExecCGI
            AllowOverride All
            AddHandler cgi-script cgi pl
            Order allow,deny
            allow from all
    </Directory>


#       ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#       <Directory "/usr/lib/cgi-bin">
#               AllowOverride All
#               Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#               Order allow,deny
#               Allow from all
#       </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>


<VirtualHost *:80>
ServerAlias subdom.mysite.com
DocumentRoot /var/www/subdom
    <Directory /var/www/subdom/cgi-bin>
            Options +ExecCGI
            AllowOverride All
            AddHandler cgi-script cgi pl
            Order allow,deny
            allow from all
    </Directory>

</VirtualHost>

非常感谢任何和所有帮助。

4

2 回答 2

0

我认为这是一个错字:在 pl 之前需要一个句号。

AddHandler cgi-script .cgi .pl

另请检查:如何配置 Apache 2 以运行 Perl CGI 脚本?

于 2012-02-21T08:48:26.230 回答
0

这听起来和看起来很熟悉:

就我而言,我的ScriptAlias指令出错了。我取消了原来的注释,但忘记配置一个新的。

一旦我正确更改并保存了我的sites-available/default配置文件:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">

..对此:

ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">

.. 并重新加载了 apache2,它才起作用:它停止将我的脚本显示为文本,并开始将它们作为脚本运行。此外,它不再/var/www/cgi-bin在浏览器中显示为目录,但现在正确显示错误:

Forbidden 
You don't have permission to access /cgi-bin/ on this server.
于 2013-11-15T23:24:14.197 回答