Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been trying to install mod_wsgl and django but iwas unsuccessful.

I am thinking of going step by step.

LEaving django aside how can i make sure that i have mod_wsgl installed correctly so that my python scripts run from website

Then i will think about django

i just want to display hello in browser using python

where can i place my and how can i check to see if mod_wsgl is insatlled properly

share|improve this question

VirtualHost config:

<Directory /path/to/webroot/>
Options +ExecCGI
AddHandler wsgi-script .wsgi


def application(environ, start_response):
    start_response('200 OK',[('Content-type','text/html')])
    return ['<html><body>Hello World!</body></html>']

If +ExecCGI is not set, you'll get:


You don't have permission to access /test.wsgi on this server.

Once you get .wsgi configured and working correctly, you'll probably want to use the Django .wsgi script from this page:

I don't know if Django's documentation has been modified based on Graham Dumpleton's work.

share|improve this answer
You need 50 rep to post an arbitrary comment. – Ignacio Vazquez-Abrams Jun 23 '10 at 2:54
I had 46 the other day, back to 1 today. but, I can't even edit or add a comment to my previous answer. Though, I could comment on this one and edit the comment. – karmawhore Jun 23 '10 at 3:23
I tried put that script in /var/www/default/test.wsgi and it says u don't have permission to access that . the file attribute is 777. – John Jun 23 '10 at 4:03
You will not get that error if you are missing +ExecCGI, you will get 'Options ExecCGI is off in this directory'. The error you quote is for different situation. Also, you are better off using WSGIScriptAlias anyway. You only need to use AddHandler in certain situations where needing to interleave WSGI scripts with static files or other dynamic applications such as PHP. – Graham Dumpleton Jun 23 '10 at 23:15
To clarify, the error I talk about is shown in the Apache error logs, not in the browser. You cant trust the error in the browser to mean that as it will be displayed for various issues, including stuff like Apache not having permissions to read a directory on path down to where script file is located which is nothing to do with ExecCGI option. – Graham Dumpleton Jun 24 '10 at 3:03


def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    print >> environ['wsgi.errors'], "application debug #1"

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    print >> environ['wsgi.errors'], "application debug #2"

    return [output]
share|improve this answer
do i ahve straight copy that code and paste in shell or i have to write in some file . i am new in python so i don't know much – John Jun 23 '10 at 2:18

Read the mod_wsgi documentation on the mod_wsgi site:

Also read:

It tells you where better place to get help on mod_wsgi setup issues is.

share|improve this answer

Sorry to contradict Graham Dumpleton, but, I tested it, and without +ExecCGI, I got the precise error posted above. My solution was tested using a freshly installed apache VM to make sure I was posting a valid solution.

I would have posted this as a comment, but, for some reason my rep was removed earlier.

share|improve this answer
Okay, a bit of confusion here. You will see your error in the browser but that error is used by Apache for a range of problems which can result in forbidden and not just the ExecCGI issue. The true error you want to pay attention to is in the Apache error log, and for the ExecCGI missing it is 'Options ExecCGI is off in this directory'. I jumped to conclusion initially that you were talking about error as displayed in the Apache error logs. – Graham Dumpleton Jun 24 '10 at 3:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.