I am using Ubuntu 10.04.
I produce a django project under /home/wong2/Code/python/django2/ named atest
and make up a wsgi file setting.wsgi within the same directory
This is actually the content of setting.wsgi :

import os 
import sys

path = '/home/wong2/Code/python/django2'

if path not in sys.path:
os.environ["DJANGO_SETTINGS_MODULE"] = "atest.settings" 
from django.core.handlers.wsgi import WSGIHandler 
application = WSGIHandler()

here is things i increase my my httpd.conf:

<VirtualHost *:80>
    ServerName localhost
    WSGIScriptAlias / /home/wong2/Code/python/django2/setting.wsgi
    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow  
        Allow from all 
    <Directory "/home/wong2/Code/python/django2/atest">
        Order allow,deny
        Allow from all

The issue is, after i visit http://localhost, it states


You do not have permission to gain access to / about this server.


The 2nd directory block does not match in which you have your WSGI script file installed. It's very bad practice though to stay the WSGI script file someplace where source code or any other sensitive files exist, ie., same directory or sub directory. Rather you need to place it inside a sub directory of their own. Thus:

WSGIScriptAlias / /home/wong2/Code/python/django2/atest/apache/setting.wsgi
<Directory "/home/wong2/Code/python/django2/atest/apache">
    Order allow,deny
    Allow from all

So, create 'apache' subdirectory under 'atest'. Move 'setting.wsgi' into that 'apache' subdirectory and alter config to above.

Your condition also might be triggered by limited permisions in your home directory as Apache cannot see inside.

Go watch:


because it describes these permissions problems in addition to issues like where you can stick your code and also the WSGI script file.

Also read: