pythonapachemod-python

how to configure apache2 mod_python


I am trying to configure apache with mod_python to run python scripts . I have tried many different configuration but none worked . my hello.py file seems like this

  from mod_python import apache

   def handler(req):
        req.log_error('handler')
        req.content_type = 'text/html'
        req.send_http_header()
        req.write('<html><head><title>Testing mod_python</title></head> <body>')
        req.write('Hello World!')
        req.write('</body></html>')
        return apache.OK

I have placed my hello.py file in /var/www/html folder and whenever I type http://localhost/hello then 404 file not found error comes and when I type extension also in url http://localhost/hello.py then full content of hello.py file is displayed in my browser. thanks in advance.


Solution

  • See this http://webpython.codepoint.net/mod_python_publisher_apache_configuration

    or

    easy way to get it, create file .htaccess in your folder /var/www/html and write in file:

    SetHandler mod_python
    PythonHandler mod_python.publisher
    PythonDebug On