Mac上使用Apache和mod_wsgi的Django安装:配置问题
我正在尝试使用mod_wsgi在Apache上运行本地Django服务器。我正在Mac上运行现成的ApacheMac上使用Apache和mod_wsgi的Django安装:配置问题,django,apache,mod-wsgi,Django,Apache,Mod Wsgi,我正在尝试使用mod_wsgi在Apache上运行本地Django服务器。我正在Mac上运行现成的Apache hobbes3@hobbes3:~/Sites/mysite$ apachectl -v Server version: Apache/2.2.21 (Unix) Server built: Nov 15 2011 15:12:57 Apache正确加载mod_wsgi hobbes3@hobbes3:~/Sites/mysite$ apachectl -M | grep wsg
hobbes3@hobbes3:~/Sites/mysite$ apachectl -v
Server version: Apache/2.2.21 (Unix)
Server built: Nov 15 2011 15:12:57
Apache正确加载mod_wsgi
hobbes3@hobbes3:~/Sites/mysite$ apachectl -M | grep wsgi
Syntax OK
wsgi_module (shared)
在我的httpd.conf
文件中,我加载了apache\u django\u wsgi.conf
,它是
WSGIDaemonProcess django
WSGIProcessGroup django
WSGIPythonHome /usr/local/Cellar/python/2.7.2/
Alias /mysite/ "/Users/hobbes3/Sites/mysite/"
<Directory "/Users/hobbes3/Sites/mysite">
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>
WSGIScriptAlias /mysite "/Users/hobbes3/Sites/mysite/apache/django.wsgi"
<Directory "/Users/hobbes3/Sites/mysite/apache">
Allow from all
</Directory>
我还可以毫无错误地重新启动Apache。但是当我尝试访问http://localhost/mysite
,浏览器只显示我的页面索引。在页面底部,它显示了Apache/2.2.21(Unix)DAV/2 mod_wsgi/3.3 Python/2.7.2 PHP/5.3.8,在本地主机端口80上安装了Suhosin补丁服务器
以前它常说无法加载MySQLdb,但现在它没有显示任何错误。但我还是看不到我的Django网站。这是前面的错误(我截断了日期和时间):
mod_wsgi(pid=74739):处理wsgi脚本“/Users/hobbes3/Sites/mysite/apache/django.wsgi”时发生异常。
回溯(最近一次呼叫最后一次):
文件“/usr/local/cillar/python/2.7.2/lib/python2.7/site packages/django/core/handlers/wsgi.py”,第272行,在调用中__
响应=自我获取响应(请求)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/core/handlers/base.py”,第169行,在get_响应中
response=self.handle\u uncaught\u异常(请求、解析器、sys.exc\u info())
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/core/handlers/base.py”,第203行,在handle_uncaught_exception中
返回调试技术响应(请求,*exc信息)
文件“/usr/local/cillar/python/2.7.2/lib/python2.7/site packages/django/views/debug.py”,第59行,技术响应
html=reporter.get\u traceback\u html()
文件“/usr/local/cillar/python/2.7.2/lib/python2.7/site packages/django/views/debug.py”,第151行,在get\u traceback\u html中
返回t.render(c)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/template/base.py”,第123行,在render中
返回self.\u呈现(上下文)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/template/base.py”,第117行,在_render中
返回self.nodelist.render(上下文)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/template/base.py”,第744行,在render中
bits.append(self.render_节点(节点,上下文))
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/template/debug.py”,第73行,在render_节点中
结果=node.render(上下文)
文件“/usr/local/cillar/python/2.7.2/lib/python2.7/site packages/django/template/debug.py”,第90行,在render中
输出=self.filter\u expression.resolve(上下文)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site-packages/django/template/base.py”,第536行,解析为
新建对象=函数(对象,*参数值)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/template/defaultfilters.py”,第695行,日期
返回格式(值,arg)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/dateformat.py”,第285行,格式为
返回df.format(格式\字符串)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/dateformat.py”,第30行,格式为
append(force_unicode(getattr(self,piece)())
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/dateformat.py”,第191行,r
返回self.format('D,jmmyh:i:so')
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/dateformat.py”,第30行,格式为
append(force_unicode(getattr(self,piece)())
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/encoding.py”,第71行,有效
s=unicode(s)
文件“/usr/local/cillar/python/2.7.2/lib/python2.7/site packages/django/utils/functional.py”,第206行,采用unicode格式
返回self.\u func(*self.\u参数,**self.\u kw)
文件“/usr/local/cillar/python/2.7.2/lib/python2.7/site packages/django/utils/translation/_init__.py”,第81行,ugettext格式
返回_trans.ugettext(消息)
文件“/usr/local/cillar/python/2.7.2/lib/python2.7/site packages/django/utils/translation/trans_real.py”,第286行,ugettext格式
返回do_translate(消息“ugettext”)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/translation/trans_real.py”,第276行,在do_translate中
_默认值=翻译(设置.语言\代码)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/translation/trans_real.py”,第185行,翻译版
默认\u translation=\u fetch(settings.LANGUAGE\u代码)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/translation/trans_real.py”,第162行,in_fetch
app=导入模块(appname)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/utils/importlib.py”,第35行,在导入模块中
__导入(名称)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/contrib/admin/_init__.py”,第3行,在
从django.contrib.admin.helpers导入操作\u复选框\u名称
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/contrib/admin/helpers.py”,第3行,在
从django.contrib.admin.util导入(展平字段集、查找字段、,
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/contrib/admin/util.py”,第1行,在
从django.db导入模型
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/db/_init___;.py”,第78行,in
连接=连接[默认\u DB\u别名]
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/db/utils.py”,第93行,在__
后端=加载\u后端(db['ENGINE'])
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site packages/django/db/utils.py”,第33行,在load_后端
返回导入_模块('.base',后端_名称)
文件“/usr/local/ceral/python/2.7.2/lib/python2.7/site-packages/django/utils/import
import os
import sys
paths = [ '/Users/hobbes3/Sites/mysite',
'/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages',
]
for path in paths:
if path not in sys.path:
sys.path.append(path)
sys.executable = '/usr/local/bin/python'
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
mod_wsgi (pid=74739): Exception occurred processing WSGI script '/Users/hobbes3/Sites/mysite/apache/django.wsgi'.
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/views/debug.py", line 59, in technical_500_response
html = reporter.get_traceback_html()
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/views/debug.py", line 151, in get_traceback_html
return t.render(c)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/template/base.py", line 123, in render
return self._render(context)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/template/base.py", line 117, in _render
return self.nodelist.render(context)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/template/base.py", line 744, in render
bits.append(self.render_node(node, context))
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/template/debug.py", line 73, in render_node
result = node.render(context)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/template/debug.py", line 90, in render
output = self.filter_expression.resolve(context)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/template/base.py", line 536, in resolve
new_obj = func(obj, *arg_vals)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/template/defaultfilters.py", line 695, in date
return format(value, arg)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/dateformat.py", line 285, in format
return df.format(format_string)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/dateformat.py", line 30, in format
pieces.append(force_unicode(getattr(self, piece)()))
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/dateformat.py", line 191, in r
return self.format('D, j M Y H:i:s O')
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/dateformat.py", line 30, in format
pieces.append(force_unicode(getattr(self, piece)()))
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/encoding.py", line 71, in force_unicode
s = unicode(s)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/functional.py", line 206, in __unicode_cast
return self.__func(*self.__args, **self.__kw)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 81, in ugettext
return _trans.ugettext(message)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 286, in ugettext
return do_translate(message, 'ugettext')
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 276, in do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 185, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 162, in _fetch
app = import_module(appname)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 3, in <module>
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/contrib/admin/helpers.py", line 3, in <module>
from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/contrib/admin/util.py", line 1, in <module>
from django.db import models
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/db/__init__.py", line 78, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/db/utils.py", line 33, in load_backend
return import_module('.base', backend_name)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
TemplateSyntaxError: Caught ImproperlyConfigured while rendering: Error loading MySQLdb module: dlopen(/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.4-x86_64.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.4-x86_64.egg/_mysql.so