【问题标题】:Setup Roundup with WSGI and Apache使用 WSGI 和 Apache 设置综述
【发布时间】:2012-09-13 14:42:39
【问题描述】:

我正在通过 Debian Squeeze 官方 repo 安装 Roundup 1.4,并希望使用 mod_wsgi 在我的 Apache 服务器上运行它。主机配置:

<VirtualHost *:80>
    ServerName support.domain.com

    WSGIScriptAlias / /var/roundup/support/apache/roundup.wsgi
    WSGIDaemonProcess support.roundup user=roundup group=roundup threads=25
    WSGIProcessGroup support.roundup

    <Directory /var/roundup/support>
        <Files roundup.wsgi>
            Order allow,deny
            Allow from all
        </Files>
    </Directory>

    # ... some logging configuration
</VirtualHost>

我使用roundup-admin install/var/roundup/support 中安装跟踪器,对其进行配置,然后使用roundup-admin initialise 进行初始化。然后我被创建apache/roundup.wsgi:

from roundup.cgi.wsgi_handler import RequestDispatcher
tracker_home = '/var/roundup/support'
application = RequestDispatcher(tracker_home)

http://support.domain.com 打开我的网站时(当然这个网址有点不同)我有 HTTP 响应 500 Internal Server Error 并登录:

mod_wsgi (pid=17433): Exception occured processing WSGI script '/var/roundup/support/apache/roundup.wsgi'.
RuntimeError: response has not been started

发生了什么事?如何正确运行 wsgi(不是 cgi)的综述?或者在哪里查看为什么没有开始响应?

编辑


Roundup 的安装手册说 wsgi 处理程序看起来像这样:

from wsgiref.simple_server import make_server

# obtain the WSGI request dispatcher
from roundup.cgi.wsgi_handler import RequestDispatcher
tracker_home = 'demo'
app = RequestDispatcher(tracker_home)

httpd = make_server('', 8917, app)
httpd.serve_forever()

但这没有反应。浏览器永远加载它而没有消息或服务器日志。我认为从 apache 模块运行的脚本启动另一台服务器并不是一个好主意。所以我尝试了另一个代码示例:

from roundup.cgi.wsgi_handler import RequestDispatcher
tracker_home = '/var/roundup/support'
application = RequestDispatcher(tracker_home)

from flup.server.fcgi import WSGIServer
WSGIServer(application).run()

但这会引发一些错误,例如:

WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!

必须有一种方法可以从 RequestDispatcher 运行我的应用程序...

【问题讨论】:

    标签: apache2 debian mod-wsgi python-2.6 roundup


    【解决方案1】:

    根据this issue,这是权限问题。解决方法:

    WSGIDaemonProcess support.roundup user=roundup group=roundup threads=25
    WSGIProcessGroup support.roundup
    

    /var/roundup/support/ 中的文件将 roundup 作为所有者和组,并具有适当的访问权限。

    【讨论】:

      【解决方案2】:

      试试:

      from roundup.cgi.wsgi_handler import RequestDispatcher
      tracker_home = '/var/roundup/support'
      application = RequestDispatcher(tracker_home)
      

      所有 mod_wsgi 需要的是一个“应用程序”对象,它是一个有效的 WSGI 应用程序入口点。

      您不需要像您一直尝试的那样自己启动 WSGI 服务器或 FASTCGI 适配器。

      【讨论】:

      • 上一次我写的编辑会抛出运行时错误并显示消息:response has not been started,但不知道为什么。