安装 mod_wsgi 出现 403 错误

安装 mod_wsgi 出现 403 错误

安装 mod_wsgi 出现 403 错误

httpd.conf 我添加了下面的代码

WSGIScriptAlias /wsgi "C:/xampp/www/htdocs/wsgi_app/wsgi_handler.py"

   <Directory "C:/xampp/www/htdocs/wsgi_app/">
    AllowOverride None
    Options None
    Order deny,allow
    Allow from all
    </Directory>

wsgi_handler.py

status = ‘200 OK’
output = ‘Hello World!’
response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]

注意:localhost 是我的虚拟主机域,它运行正常,但是当我请求时http://localhost/wsgi/出现 403 错误。

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "C:/xampp/www/htdocs/localhost"
    ServerName localhost
    ServerAlias www.localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" combined
</VirtualHost>

错误日志

[Wed Jul 04 06:01:54 2012] [error] [client 127.0.0.1] File does not exist: C:/xampp/www/htdocs/localhost/favicon.ico
[Wed Jul 04 06:01:54 2012] [error] [client 127.0.0.1] client denied by server configuration: C:/xampp/Bin/apache
[Wed Jul 04 06:01:58 2012] [error] [client 127.0.0.1] Options ExecCGI is off in this directory: C:/xampp/www/htdocs/wsgi_app/wsgi_handler.py
[Wed Jul 04 06:01:58 2012] [error] [client 127.0.0.1] client denied by server configuration: C:/xampp/Bin/apache
[Wed Jul 04 06:01:58 2012] [error] [client 127.0.0.1] File does not exist: C:/xampp/www/htdocs/localhost/favicon.ico
[Wed Jul 04 06:01:58 2012] [error] [client 127.0.0.1] client denied by server configuration: C:/xampp/Bin/apache

注意:我的 apache 不在 c:/xampp/bin/apache 中,而是在 c:/xampp/bin/server-apache/ 中

答案1

您在 <Directory> 和 <VirtualHost> 指令中使用了不同的目录。

在您的 Directory 指令中,您有

 <Directory "C:/xampp/htdocs/wsgi_app/">

在 VirtualHost 中你有

DocumentRoot "C:/xampp/www/htdocs/localhost"

您需要修复它,以便访问规则和 DocumentRoot 就您想要使用的目录达成一致。

答案2

该错误表明c:/xampp/www/htdocs/wsgi_app/wsgi_handler.py目录的 Options ExecCGI 已关闭。

您是否尝试过打开 Options ExecCGI?更改Options NoneOptions +ExecCGI

答案3

您不允许访问文档根目录,只允许访问 WSGI 根目录。

在您的块中添加此内容<VirtualHost *:80>

<Directory "C:/xampp/www/htdocs/localhost">
    Order allow,deny
    Allow from all
</Directory>

相关内容