为什么我的Django安装提供空的HTTP响应?

时间:2010-07-30 22:33:23

标签: python django mod-wsgi

最终更新:有一个与LoadModule python_module modules/mod_python.so发生冲突的迷路mod_wsgi。删除LoadModule使一切都恢复正常。


我正在使用Django设置一个生产服务器并跟随the Django tutorial,但在我访问Error 324 (net::ERR_EMPTY_RESPONSE): Unknown error.时收到一个空白页面(或者,就像Chrome想要报告http://domain.com/mysite一样)

# httpd.conf

LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /mysite /home/gibson/mysite/django.wsgi

# django.wsgi

import os
import sys

sys.path.append('/home/gibson')

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

我还尝试使用一个非常基本的mod_wsgi测试应用程序(如mod_wsgi wiki中所示),其行为符合预期:

# django.wsgi (test)

def application(environ, start_response):
    status = '200 OK'
    output = 'i live!'
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)
    return [output]

还有什么我可以忘记的吗?我很欣赏这种见解。

小更新:对于咯咯笑,我检查了我的Apache error_log:

[notice] child pid 18356 exit signal Segmentation fault (11)

谷歌搜索这个宝石返回了一些关于Django的缓存机制(我没有使用)和与加载mod_python模块(我已经在我的httpd.conf中注释掉)的冲突。

更新2:(为简洁起见删除了评论)

# settings.py

DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
)
MANAGERS = ADMINS
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': '/home/gibson/mysite/sqlite3.db',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '',
    }
}
TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
MEDIA_ROOT = ''
MEDIA_URL = ''
ADMIN_MEDIA_PREFIX = '/media/'
SECRET_KEY = '[redacted]'
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'mysite.urls'
TEMPLATE_DIRS = (
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
)


# urls.py

from django.conf.urls.defaults import *
urlpatterns = patterns('',)

1 个答案:

答案 0 :(得分:2)

确保Apache中没有安装冲突的模块。具体来说,检查mod_python或类似的。

相关问题