Django标题之前的脚本输出结束

时间:2015-02-02 12:00:39

标签: python django mod-wsgi

我的一台服务器会定期停止提供内容,并在Vhost错误日志中找到以下错误:

[Mon Feb 02 10:27:41.692362 2015] [core:error] [pid 13013] [client xxx.xxx.xxx.xxx:41537] End of script output before headers: wsgi.py
[Mon Feb 02 10:27:41.692365 2015] [core:error] [pid 13025] [client xxx.xxx.xxx.xxx:41188] End of script output before headers: wsgi.py
[Mon Feb 02 10:27:41.692423 2015] [core:error] [pid 14787] [client xxx.xxx.xxx.xxx:36388] End of script output before headers: wsgi.py
[Mon Feb 02 10:27:41.692451 2015] [core:error] [pid 12994] [client xxx.xxx.xxx.xxx:38770] End of script output before headers: wsgi.py

此apache锁定并停止提供内容后。非常感谢。

wsgi.py:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

虚拟主机:

WSGIScriptAlias / /var/www/vhosts/zipper/src/core/wsgi.py
WSGIDaemonProcess zipper python-path=/var/www/vhosts/zipper/src:/var/www/vhosts/.virtualenvs/zipper/lib/python2.7/site-packages
WSGIProcessGroup zipper

<Directory /var/www/vhosts/zipper/src/>
    <Files wsgi.py>
         Require all granted
    </Files>
</Directory>

编辑#1

Django版本:1.6.4 Mod_WSGI版本:3.4-4ubuntu2.1.14.04.2

2 个答案:

答案 0 :(得分:0)

ServerName localhost
ServerAlias localhost
ServerAdmin raghav@xyz.com

<Directory /var/www/mysite/mysite>
AddHandler wsgi-script .py
Options +ExecCGI
</Directory>

DocumentRoot /var/www/mysite
WSGIDaemonProcess myproject python-path=/var/www/mysite:/var/www/environ/lib/python2.7/site-packages
#WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py

WSGIApplicationGroup %{GLOBAL}

<Directory /var/www/mysite/mysite/>
order deny,allow
Allow from all
</Directory>

我在阅读几篇博客后也遇到了同样的问题,这个配置对我来说很有用。 试试这个

答案 1 :(得分:0)

尝试添加指令:

WSGIApplicationGroup%{GLOBAL}

在WSGIProcessGroup行之后。

带有C扩展组件的各种第三方Python软件包存在一些已知问题,这意味着它们无法与Python子解释器一起正常工作。该指令强制应用程序在主解释器上下文中运行。这样的模块很高兴。