始终下载虚拟主机 cgi-bin 中的 Perl 文件(Debian 6 和 Apache2)

发布于 2025-01-07 02:55:11 字数 1968 浏览 0 评论 0原文

我一直在绞尽脑汁地试图让它工作,但无论我做什么,我都无法让 .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>

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

I have been tearing my hair out trying to get this working but no matter what I do I can't get .pl files to execute in the cgi-bin of my virtual directory. I have been searching for solutions for the past 4 hours and have tried everything I have come across, and nothing works for me. Perl files are executing perfectly for my default site, just not for my virtual host. The only mopdified file in my Apache2 configuration is the /etc/apache2/sites-available/default file, and currently it is as follows (except for the sitename):

<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>

Any and all help is very much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柳絮泡泡 2025-01-14 02:55:11

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

AddHandler cgi-script .cgi .pl

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

I think it is a typo: You need a period before pl.

AddHandler cgi-script .cgi .pl

Also check this: How do I configure Apache 2 to run Perl CGI scripts?

奈何桥上唱咆哮 2025-01-14 02:55:11

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

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

This sounds and looks familiar:

In my case, I made a mistake with my ScriptAlias directive. I uncommented the original one, but forgot to configure a new one.

As soon as I correctly changed and saved my sites-available/default config file from this:

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

.. to this:

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

.. and reloaded apache2, it just worked: it stopped displaying my scripts as text, and started running them as a script. Also, it no longer displayed /var/www/cgi-bin as a directory in the browser, but now correctly displays the error:

Forbidden 
You don't have permission to access /cgi-bin/ on this server.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文