最终更新:有一个与 mod_wsgi
冲突的 LoadModule python_module module/mod_python.so
。删除该 LoadModule 使一切再次正常工作。
我正在使用 Django 设置生产服务器,并按照 the Django tutorial 进行操作。 ,但当我访问 http://domain.com/mysite 时却收到空白页面(或者,正如 Chrome 喜欢报告的那样,
.错误 324 (net::ERR_EMPTY_RESPONSE):未知错误。
)
# 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)
谷歌搜索此 gem 返回了一些有关 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('',)
最佳答案
确保 Apache 中没有安装冲突的模块。具体来说,检查 mod_python 或类似的。
关于python - 为什么我的 Django 安装提供空的 HTTP 响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3375836/