我正在 Django 上开发应用程序,并准备转移到部署服务器。我可以在 apache 上运行一个新的 django 项目(我可以看到欢迎页面)。但是,当我将原始项目的文件复制到 apache 项目目录时,我开始收到错误。这是来自 apache/error.log 的示例。
[Wed Jan 26 19:22:08 2011] [error] [client 127.0.0.1] TemplateSyntaxError: Caught ImportError while rendering: No module named charts
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1] mod_wsgi (pid=4670): Exception occurred processing WSGI script '/srv/www/enpass/apache/django.wsgi'.
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1] Traceback (most recent call last):
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1] File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1] response = self.get_response(request)
[Wed Jan 26 19:22:36 2011] [error] [client 127.0.0.1] File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 141, in get_response
我的 django.wsgi 文件看起来像
import os
import sys
path = '/srv/www'
if path not in sys.path:
sys.path.insert(0, '/srv/www')
os.environ['DJANGO_SETTINGS_MODULE'] = 'enpass.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我已经更改了文件中的所有路径以适应新的目录结构,所以我很确定那不是问题。FIY,我按照本教程中给出的步骤http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/