python - Django 在标题之前结束脚本输出

标签 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

最佳答案

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>

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

关于python - Django 在标题之前结束脚本输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28277322/

相关文章:

python - Scala 等价于 Python 返回多个项目

python - WSGIPythonPath应该在我的virtualenv中指向何处?

python - Django+Apache ModuleNotFoundError : No module named 'myproject' 错误

python - 如何将图像文件数据集加载到 TensorFlow Jupyter Notebook

python - 比较两个列表并找到唯一值

python - python中间件捕获错误?

python - 用于具有多个左连接的 SQL 查询的 Django ORM

python - 使用请求检查损坏的链接后,Django 网站加载缓慢

python - 如何使用 django-admin.py 运行特定测试?

python - django : ImportError No module named myapp. views.hometest