Django、apache、mod_wsgi - 错误 : Premature end of script headers

标签 django apache apache2 mod-wsgi centos

Apache 以 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.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 但我仍然不明白解决方案。

最佳答案

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

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

并点击那里的链接。

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

关于Django、apache、mod_wsgi - 错误 : Premature end of script headers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4501817/

相关文章:

python - Django:选择具有最大时间戳的值或加入同一个表

python - 我可以添加对媒体 django 媒体文件的权限吗?

apache - .htaccess 在使用别名 URI 时被忽略

php - Apache 无法访问我的主目录中的文件夹

apache - 处理您的请求时发生错误

python - 如何检查哪个 Python 解释器用于在 apache2 中运行 WSGI 脚本?

python - Apache 2 + mod_wsgi + WSGIScriptAlias

django - 如何将 django 中的查询集转换为 json

django - 向Django Auth用户模型添加便捷方法的最佳方法?

php - 使 www.example.com 和 example.com 使用相同 session 变量的最佳方法?