【问题标题】:Perl files in Virtualhosts cgi-bin are always downloaded (Debian 6 and Apache2)始终下载 Virtualhosts cgi-bin 中的 Perl 文件(Debian 6 和 Apache2)
【发布时间】:2012-03-11 08:37:14
【问题描述】:

我一直在努力让它工作,但无论我做什么,我都无法让 .pl 文件在我的虚拟目录的 cgi-bin 中执行。在过去的 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>

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

【问题讨论】:

  • 将什么写入 apache accesserror 日志?每次尝试执行脚本时是否至少更新了一个日志?
  • 我最终自己解决了这个问题。 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ # 改为 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ # 缺少最后一个正斜杠。

标签: perl apache2 debian virtualhost cgi-bin


【解决方案1】:

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

AddHandler cgi-script .cgi .pl

还要检查这个:How do I configure Apache 2 to run Perl CGI scripts?

【讨论】:

    【解决方案2】:

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

    就我而言,我的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.
    

    【讨论】:

      猜你喜欢
      • 2011-05-26
      • 1970-01-01
      • 2014-02-28
      • 2012-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-11
      • 1970-01-01
      相关资源
      最近更新 更多