【问题标题】:how to configure apache2 mod_python如何配置 apache2 mod_python
【发布时间】:2015-05-02 13:44:49
【问题描述】:

我正在尝试使用 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 file not found 错误,当我也在 url http://localhost/hello.py 中输入扩展名时,就会出现 hello 的全部内容。 py 文件显示在我的浏览器中。 提前致谢。

【问题讨论】:

    标签: python apache mod-python


    【解决方案1】:

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

    获取它的简单方法,在您的文件夹 /var/www/html 中创建文件 .htaccess 并写入文件:

    SetHandler mod_python
    PythonHandler mod_python.publisher
    PythonDebug On
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-14
      • 2011-01-26
      • 1970-01-01
      • 2011-03-11
      • 2013-10-03
      • 2018-05-30
      相关资源
      最近更新 更多