简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM