繁体   English   中英

如何配置apache2 mod_python

[英]how to configure apache2 mod_python

我正在尝试使用mod_python配置apache以运行python脚本。 我尝试了许多不同的配置,但均无济于事。 我的hello.py文件看起来像这样

  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

我已将我的hello.py文件放在/ var / www / html文件夹中,每当我键入http:// localhost / hello时,都找不到404文件,并且在URL http:// localhost / hello中键入扩展名时也会出现错误。 py,然后hello.py文件的完整内容显示在我的浏览器中。 提前致谢。

看到这个http://webpython.codepoint.net/mod_python_publisher_apache_configuration

要么

一种简单的方法,在文件夹/ var / www / html中创建文件.htaccess并写入文件:

SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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