4

I have installed the Python , apache. The command line programs are working with python.

I have two virtual hosts in apache

site1.local
site2.local

WHat i want is i place file in site1 root directory and it display hello in browser

with mod_wsgl only without cgi

2 Answers 2

4

In it's most simplest form..

Create a file called hello_world.wsgi with the following contents. This should be outside of your DocumentRoot so that Apache is unable to serve it up as plain text:

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

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

    return [output]

Then configure your vhost to serve all requests beneath / from that script:

WSGIScriptAlias / <path_to_script>/hello_world.wsgi
2
  • i am trying that and will let u know. Thanks for being simple and straight to point
    – John
    Jun 24, 2010 at 0:44
  • Thanks buddy i finally displayed hello in browser. I am confused with one thing , i was epecting to run something like hello.py and now i am running wsgi so it means on web i can't have something like hello.py and with code in it. Where will i write my all code?
    – John
    Jun 24, 2010 at 7:00
1

Have you actually tried reading the mod_wsgi documentation. That is what it is there for.

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

1
  • From the man himself no less!
    – kevinarpe
    Mar 2, 2016 at 13:36

You must log in to answer this question.