【问题标题】:Apache/Wsgi - Script timed out before returning headersApache/Wsgi - 脚本在返回标头之前超时
【发布时间】:2015-07-22 08:27:22
【问题描述】:

我在 Ubuntu 上遇到 Apache/wsgi 的问题。我正在尝试为 django 站点提供服务。 我已经在 SO 和其他网站上阅读了所有相同的问题,但我真的无法修复它。

我遇到了和其他会员一样的问题。 2 - 3 分钟后,请求以 500 错误结束,日志告诉我:脚本在返回标头之前超时 - wsgi.py。

权利还可以,Apache 2.4.7,libapache2-mod-wsgi 4ubuntu2.1.14.04.2。

启用的模组列表:

  • access_compat.load
  • alias.conf
  • alias.load
  • auth_basic.load
  • authn_core.load
  • authn_file.load
  • authz_core.load
  • authz_groupfile.load
  • authz_host.load
  • authz_user.load
  • autoindex.conf
  • 自动索引加载
  • cgi.load
  • deflate.conf
  • deflate.load
  • dir.conf
  • dir.load
  • env.load
  • filter.load
  • mime.conf
  • mime.load
  • mpm_prefork.conf
  • mpm_prefork.load
  • negotiation.conf
  • negotiation.load
  • php5.conf
  • php5.load
  • reqtimeout.conf
  • reqtimeout.load
  • rewrite.load
  • setenvif.conf
  • setenvif.load
  • status.conf
  • status.load
  • wsgi.conf
  • wsgi.load

这是我的虚拟主机

<VirtualHost *:80>
    ServerAdmin info@rescuecode.fr
    ServerName fiches.rescuecode.fr

    DocumentRoot /home/repos/git/rescuecode-fiches

    WSGIDaemonProcess rescuecode-fiches python-path=/home/repos/git/rescuecode-fiches:/home/virtualenvs/rescuecode-fiches/lib/python2.7/site-packages processes=4 threads=25
    WSGIProcessGroup rescuecode-fiches
    WSGIScriptAlias / /home/repos/git/rescuecode-fiches/project/wsgi.py
    WSGIApplicationGroup %{GLOBAL}

    Alias /static /home/repos/git/rescuecode-fiches/project/static/

    <Directory /home/repos/git/rescuecode-fiches/project/static>
            Require all granted
    </Directory>

    Alias /site_media /home/repos/git/rescuecode-fiches/project/site_media/

    <Directory /home/repos/git/rescuecode-fiches/project/site_media>
            Require all granted
    </Directory>

    <Directory /home/repos/git/rescuecode-fiches/project>
            <Files wsgi.py>
                    Require all granted
            </Files>
    </Directory>

    Loglevel warn
    ErrorLog /var/log/apache2/fiches.rescuecode.fr-error.log
    CustomLog /var/log/apache2/fiches.rescuecode.fr-access.log combined
    ServerSignature Off

谁能告诉我哪里错了?

谢谢!

【问题讨论】:

  • 主要(不是 VirtualHost)Apache 日志文件说什么?它是否表明进程崩溃了?将 LogLevel 提高到整个 Apache 和 VirtualHost 的信息,您可能会获得更多信息。
  • mod_wsgi (pid=10409):未能正确配置守护进程,进程处于未指定状态。延迟后重新启动守护进程。
  • 我去看看我是否在网上找到了什么!已经谢谢你了:)
  • 我猜这是目录问题。我有/home/repos,如果我理解,他会搜索/home/mercurial:没有这样的文件或目录:mod_wsgi 无法更改工作目录'/home/mercurial'

标签: python django apache mod-wsgi


【解决方案1】:

谢谢格雷厄姆·邓普顿!!

我将此添加到虚拟主机:

WSGIDaemonProcess home=/home/repos

现在一切正常 :) 是目录问题!

【讨论】:

  • 旧版本的 mod_wsgi 会盲目地忽略守护进程明确设置为的用户缺少主目录并回退到使用“/”。从安全的角度来看,这涉及到一些问题,因此如果有效目录不针对系统密码文件中的帐户,则行为已更改为强制明确指定主目录。
猜你喜欢
  • 2023-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-08
  • 2019-01-31
  • 2016-05-04
相关资源
最近更新 更多