【问题标题】:Ubuntu Apache can't access cgi-bin folderUbuntu Apache 无法访问 cgi-bin 文件夹
【发布时间】:2016-12-16 16:14:42
【问题描述】:

我在 DigitalOcean 上创建了一个 droplet,但无法运行 cgi-bin 文件夹中的 python 脚本。我试过了

sudo a2enmod cgi
chmod a+rwx cgi-bin

还给文件 chmod 755 但它不起作用。当我尝试访问 cgi-bin 文件夹时,它给出了 Forbidden 错误并说 You don't have permission to access /cgi-bin/ on this server. 有人可以帮忙吗?

我的配置文件

<VirtualHost *:80>

    ScriptAlias /cgi-bin/ "/var/www/test/cgi-bin/"
    <Directory /var/www/test/cgi-bin/>
            AllowOverride All
            Options ExecCGI
            AddHandler cgi-script .cgi .pl .tcl .py
            Order allow,deny
            Allow from all
    </Directory>

    <Directory "/var/www/test/">
            AllowOverride All
            Options Indexes MultiViews FollowSymLinks ExecCGI
            Require all granted
    </Directory>

    ServerAdmin webmaster@localhost
    DocumentRoot "/var/www/test"

</VirtualHost>

我还在文档根目录中创建了一个测试 python 文件,当我打开它时,它的行为就像一个文本文件。

【问题讨论】:

    标签: python apache ubuntu cgi


    【解决方案1】:

    您可以尝试将以下行添加到您的 httpd.conf 或您的网络服务器配置文件中

    <Files ~ "\.(py|cgi)$">
        SetHandler python-script
        Options +ExecCGI
    </Files>
    

    另见:mod-python

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-26
      • 2016-12-18
      • 2022-07-06
      • 2015-06-07
      相关资源
      最近更新 更多