【问题标题】:Forbidden You don't have permission to access this resource. PYTHON on ApacheForbidden 您无权访问此资源。 Apache 上的 Python
【发布时间】:2021-04-03 06:43:19
【问题描述】:

我正在尝试在 apache 上执行 python 脚本,但出现此错误:Forbidden You don't have permission to access this resource; 在问这个问题之前,我在谷歌上搜索了几个小时,我找到了“csrf token”,但它没有用;我找到了我在下面发布的配置,它们也不起作用...... 我不知道是什么导致它不起作用。

这是我的 Python 脚本:

print ('Content-type: text/html')
print
print ('<html><head>')
print ('</head><body>')
print ('Hello.')
print ('</body></html>')

这些是我添加的 httpd.conf 配置:

<Directory />
    Options Indexes FollowSymLinks ExecCGI
    AddHandler cgi-script .cgi .py
    AllowOverride none
    Require all granted
</Directory>

AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict

这些是我的 default.conf 配置:

<VirtualHost _default_:80>
    DocumentRoot "C:\Users\User\Web\default"
    <Directory "C:\Users\User\Web\default">
        AllowOverride None
        Options FollowSymLinks
        Require all granted #i tried also with denied
    </Directory>
</VirtualHost>

【问题讨论】:

    标签: python html apache server httpd.conf


    【解决方案1】:

    不确定你是把你的脚本放在根文件夹还是单独放在 cgi 文件夹中。 可以试试下面的:

    ScriptAlias \cgi-bin\ C:\Users\User\Web\cgi-bin\

    <Directory "C:\Users\User\Web\cgi-bin\">
    SetHandler cgi-script
    Options +ExecCGI +FollowSymLinks
    AllowOverride None
    </Directory>
    

    【讨论】:

    • 什么?这条路径C:\Users\User\Web\default 是我网站的路径。 cgi-bin 的路径是这个C:\Program Files\Apache\cgi-bin。我必须在 VirtualHost -Directory 中使用这个吗?
    猜你喜欢
    • 1970-01-01
    • 2020-05-07
    • 2021-08-17
    • 2022-08-03
    • 2022-08-02
    • 2021-12-27
    • 2020-07-05
    • 2019-02-16
    • 2020-05-30
    相关资源
    最近更新 更多