Forbidden 您无权访问此资源。 Apache 上的 Python

时间:2020-12-25 02:09:11

标签: python html apache server httpd.conf

我正在尝试在 apache 上执行 python 脚本,但出现此错误:禁止您无权访问此资源; 在问这个问题之前,我在谷歌上搜索了几个小时,我找到了“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>

1 个答案:

答案 0 :(得分:0)

不确定您是将脚本放在根文件夹中还是单独放在 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>
相关问题