Django、apache、mod_wsgi - 错误:脚本头过早结束 [英] Django, apache, mod_wsgi - Error: Premature end of script headers

查看:34
本文介绍了Django、apache、mod_wsgi - 错误:脚本头过早结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apache 以调试模式登录:

Apache logs in mode debug:

[Tue Dec 21 11:36:33 2010] [info] [client 1.53.149.114] mod_wsgi (pid=24831, process='mysite', application='mysite.com|'): Loading WSGI script '/home/anhtran/webapps/mysite.com/django.wsgi'.
[Tue Dec 21 11:36:33 2010] [error] [client 1.53.149.114] Premature end of script headers: django.wsgi
[Tue Dec 21 11:36:33 2010] [notice] child pid 24831 exit signal Segmentation fault (11)
[Tue Dec 21 11:36:33 2010] [info] mod_wsgi (pid=24980): Attach interpreter ''.

我的配置文件:

WSGISocketPrefix /tmp/wsgi

<VirtualHost *:80>
   ServerName mysite.com
   ServerAlias www.mysite.com
   ServerAdmin admin@mysite.com

   DocumentRoot /home/anhtran/webapps/mysite.com/public_html

   WSGIDaemonProcess mysite processes=5 threads=25
   WSGIProcessGroup mysite
   WSGIScriptAlias / /home/anhtran/webapps/mysite.com/django.wsgi

   LogLevel debug

   <Directory /home/anhtran/webapps/mysite.com/mysite>
      Order allow,deny
      Allow from all
   </Directory>

</VirtualHost>

Django 在没有数据连接的基本项目中工作正常,例如 MySQLdb 或 sqlite3.我正在使用 CentOS 5 64 位、apache 2.x、mod_wsgi 3.2.我认为这不是 Django 的问题,但我不知道.大家能修好吗?帮我.谢谢!:)

Django works fine in a basic project without a data connection such as MySQLdb or sqlite3. I'm using CentOS 5 64 bit, apache 2.x, mod_wsgi 3.2. I think this is not a problem of Django, but I have no idea for it. Everybody can fix it? Help me. Thanks! :)

django.wsgi

django.wsgi

#!/usr/local/bin/python
import os, site, sys

# add the virtual environment path
site.addsitedir('/home/anhtran/webapps/mysite.com/env/lib/python2.6/site-packages')
site.addsitedir('/home/anhtran/webapps/mysite.com/mysite')
site.addsitedir('/home/anhtran/webapps/mysite.com')

# fix markdown.py (and potentially others) using stdout
sys.stdout = sys.stderr

#Calculate the path based on the location of the WSGI script.
project = os.path.dirname(__file__)
workspace = os.path.dirname(project)
sys.path.append(workspace)

os.environ['PYTHON_EGG_CACHE'] = '/home/anhtran/webapps/mysite.com/.python-eggs'
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()

我在此链接中阅读了一些问题:http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions但我仍然不明白解决方案.

I've read some questions in this link: http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions But I still don't understand the solutions.

推荐答案

守护进程崩溃.请参阅 mod_wsgi 常见问题解答中有关崩溃原因的评论:

The daemon process crashed. See comments in the mod_wsgi FAQ about what causes crashes:

http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions

并点击那里的链接.

最终的原因可能有很多,包括同时加载不兼容的 mod_python、使用不支持子解释器的 Python C 扩展模块、Apache 使用的共享库版本和/或 PHP 中的扩展模块不兼容等.

Ultimately the cause can be many things, including loading incompatible mod_python at same time, using Python C extension module that doesn't work with sub interpreters, incompatible shared library versions used by Apache and/or extension modules in PHP etc.

这篇关于Django、apache、mod_wsgi - 错误:脚本头过早结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆