Python Django-mezzanine运行失败

时间:2014-03-23 14:31:03

标签: python django mezzanine

我安装了django + mezzanine + mysql + apache2 + nginx。

[Sun Mar 23 10:01:02.382418 2014] [authz_core:debug] [pid 1131] mod_authz_core.c(828): [client xxx.xxx.xxx.xxx:36626] AH01628: authorization result: granted (no directives)
[Sun Mar 23 10:01:02.382520 2014] [authz_core:debug] [pid 1131] mod_authz_core.c(828): [client xxx.xxx.xxx.xxx:36626] AH01628: authorization result: granted (no directives)
[Sun Mar 23 10:01:02.384258 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626] mod_wsgi (pid=1131): Exception occurred processing WSGI script '/var/www/admin/data/www/sitename/django.wsgi'.
[Sun Mar 23 10:01:02.384297 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626] Traceback (most recent call last):
[Sun Mar 23 10:01:02.384328 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]   File "/var/www/admin/data/www/sitename/django.wsgi", line 36, in application
[Sun Mar 23 10:01:02.384374 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]     return _application(environ, start_response)
[Sun Mar 23 10:01:02.384391 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Sun Mar 23 10:01:02.384417 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]     self.load_middleware()
[Sun Mar 23 10:01:02.384432 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
[Sun Mar 23 10:01:02.384455 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun Mar 23 10:01:02.384469 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]   File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
[Sun Mar 23 10:01:02.384492 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]     self._setup()
[Sun Mar 23 10:01:02.384506 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
[Sun Mar 23 10:01:02.384528 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]     self._wrapped = Settings(settings_module)
[Sun Mar 23 10:01:02.384541 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 93, in __init__
[Sun Mar 23 10:01:02.384563 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]     mod = importlib.import_module(self.SETTINGS_MODULE)
[Sun Mar 23 10:01:02.384577 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]   File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
[Sun Mar 23 10:01:02.384598 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]     __import__(name)
[Sun Mar 23 10:01:02.384650 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]   File "/var/www/admin/data/www/sitename/edparfum-app/settings.py", line 311
[Sun Mar 23 10:01:02.384661 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]     'USER': \xe2\x80\x98root\xe2\x80\x99,
[Sun Mar 23 10:01:02.384671 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626]             ^
[Sun Mar 23 10:01:02.384678 2014] [:error] [pid 1131] [client xxx.xxx.xxx.xxx:36626] SyntaxError: invalid syntax

这里是文件内容:/var/www/admin/data/www/sitename/django.wsgi

import os, sys
from urllib import quote
sys.path.append('/var/www/admin/data/www/sitename/edparfum-app')
sys.path.append('/var/www/admin/data/www/sitename/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler()
def reconstruct_url(environ, HTTP_HOST=None):
    url = environ['wsgi.url_scheme']+'://'
    if environ.get('HTTP_HOST') and not HTTP_HOST:
        url += environ['HTTP_HOST']
    elif HTTP_HOST:
        url += HTTP_HOST
    else:
        url += environ['SERVER_NAME']

        if environ['wsgi.url_scheme'] == 'https':
            if environ['SERVER_PORT'] != '443':
               url += ':' + environ['SERVER_PORT']
        else:
            if environ['SERVER_PORT'] != '80':
               url += ':' + environ['SERVER_PORT']

    url += quote(environ.get('SCRIPT_NAME', ''))
    url += quote(environ.get('PATH_INFO', ''))
    if environ.get('QUERY_STRING'):
        url += '?' + environ['QUERY_STRING']
    return url

def application(environ, start_response):
  if environ['HTTP_HOST'] == 'www.sitename.ru':
    tourl = reconstruct_url(environ, 'sitename.ru')
    start_response('301 Redirect', [('Location', tourl),])
    return []
  return _application(environ, start_response)

尝试在服务器Django-mezzanne上运行。似乎一切都已设置但不起作用。我将不胜感激任何帮助。如果您要发布其他文件的内容。

1 个答案:

答案 0 :(得分:1)

它看起来像您用来编辑settings.py使用的unicode引号‘’的文本编辑器,而不是实际的撇号''或引号字符""。它应该是:

'USER': 'root',

而不是:

'USER': \xe2\x80\x98root\xe2\x80\x99,

最简单的解决方法是在USER关键字周围复制和粘贴引号,但最好找一个使用python所需的正确引号的文本编辑器。