Installing mod_wsgi giving 403 error

apache-2.2mod-wsgi

installing mod_wsgi giving 403 error

httpd.conf i added code below

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]

Note: localhost is my virtual host domain and it is working fine but when i request http://localhost/wsgi/ got 403 error.

<VirtualHost *:80>
    ServerAdmin postmaster@dummy-host2.localhost
    DocumentRoot "C:/xampp/www/htdocs/localhost"
    ServerName localhost
    ServerAlias www.localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" combined
</VirtualHost>

Error log

[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

Note: My apache is not in c:/xampp/bin/apache it is in c:/xampp/bin/server-apache/

Best Answer

You're using different directories in your <Directory> and you <VirtualHost> directives.

In your Directory directive you've got

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

In the VirtualHost you've got

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

You need to fix it so the access rules and the DocumentRoot agree on the directory you want to use.