[Fixed]-Apache mod_wsgi error: Forbidden You don't have permission to access / on this server


The second directory block doesn’t match where you have your WSGI script file installed. It is very bad practice though to stick the WSGI script file in a location where source code or other sensitive files exist, ie., same directory or sub directory. Instead you should stick it in a sub directory of its 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 change config to above.

Your problem also may be caused by restrictive permisions on your home directory as Apache cannot see inside.

Go watch:


as it explains these permissions problems as well as issues like where to stick your code and the WSGI script file.

Also read:



With Django 1.5+ you should use the suggested way described in the documentation:

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted



I had the same problem due to restricted file permissions.

By default your home folder user has the settings:

ls -l /home/

drwx—— 36 user user 12288 Nov 28 20:56 user

meaning that no one else but yourself is able to even browse that folder.

Adding execute option to the folder fixed my problem

chmod o+x /home/user/
ls -l /home/

drwx—–x 36 user user 12288 Nov 28 20:56 user



try http://localhost/index.html does that show the apache page?

If you wsgi is configured on root correctly it wont.

You get that error message because you might be asking the webserver for the directory listing of www folder


My projects are always in

and server files i put in

Here is my go to wsgi script

import os, sys

import logging
logger =logging.getLogger("")
handler = logging.StreamHandler(sys.stderr)
formatter = logging.Formatter('%(levelname)-8s %(messages)s')

sys.stdout = sys.stderr
from os.path import abspath, dirname, join
import site

PROJECT_ROOT = abspath(join(dirname(__file__), "../pysrc"))
SETTINGS_LOC = abspath(join(PROJECT_ROOT, ''))
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"

from django.core.management import setup_environ
import settings

sys.path.insert(0, join(PROJECT_ROOT, "apps"))

from django.core.handlers.wsgi import WSGIHandler

application = WSGIHandler()

and i use a vhost.conf

WSGIDaemonProcess pinax_demo user=www-data group=www-data threads=10 python-path=/var/.virtualenvs/pinax_demo/lib/python2.6/site-packages

<Directory /var/py_proj/pinax_demo/server/>
    Order deny,allow
    Allow from all

Alias /pinax_demo /var/py_proj/pinax_demo/server/pinax_demo.wsgi
<Location /pinax_demo/>
    #WSGIProcessGroup must match the WSGIDaemonProcess
    WSGIProcessGroup pinax_demo
    SetHandler wsgi-script
    Options +ExecCGI

which i include in the sites-available folder in a file that looks like this

<VirtualHost *:8080>
        DocumentRoot /var/www/

        <Directory /var/www/>
                Order deny,allow
                Allow from all
                Options -Indexes FollowSymLinks
                DirectoryIndex index.php
                AllowOverride None

        ServerAdmin oto@example.com

        LogLevel error
        ErrorLog  /var/srv_logs/apache_error.log
        CustomLog  /var/srv_logs/apache_access.log combined
        Include /var/py_proj/pinax_demo/server/vhost.conf
        Include /var/py_proj/<other>/server/vhost.conf
        Include /var/py_proj/<other>/server/vhost.conf


httpd.conf is empty. Apache is also terrible at sending static files so i have my apache setup on port 8080 and nginx setup on port 80 which forwards to apache. You should be able to just change the port on my sites-avaiable file to run it without nginx but i would not go live that way


You may get a surprise where your WSGI has its home directory! On my admittedly naive wsgi_mod installation, it is / – I was so surprised I had to write this script to make sure:

import os

def application(environ, start_response):
    status = '200 OK'; e=os.listdir(os.getcwd())
    output = '''WSGI %s<hr>'''%(e)
    response_headers = [('Content-type', 'text/html'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)
    return [output]

That means imported applications will need a full path to be found, e.g.:

from DataCommon import page

This is the recommended (by Google) approach to this:

import sys; path='/home/foo/www/Forms';
if path not in sys.path: sys.path.append(path)

Leave a comment