2

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 hello.py and how can i check to see if mod_wsgl is insatlled properly

Graham Dumpleton
  • 6,090
  • 2
  • 21
  • 19

4 Answers4

2

VirtualHost config:

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

test.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:

Forbidden

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:

http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

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

karmawhore
  • 3,865
  • 18
  • 9
  • You need 50 rep to post an arbitrary comment. – Ignacio Vazquez-Abrams Jun 23 '10 at 02: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 03: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. –  Jun 23 '10 at 04: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 03:03
1

From http://code.google.com/p/modwsgi/wiki/DebuggingTechniques

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]
karmawhore
  • 3,865
  • 18
  • 9
  • 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 –  Jun 23 '10 at 02:18
0

Read the mod_wsgi documentation on the mod_wsgi site:

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

Also read:

http://code.google.com/p/modwsgi/wiki/WhereToGetHelp

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

Graham Dumpleton
  • 6,090
  • 2
  • 21
  • 19
0

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.

karmawhore
  • 3,865
  • 18
  • 9
  • 1
    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 03:01