500 ошибка сервера на сайте django после перехода на сервер
Я использовал сайт Django на локальном компьютере с Ubuntu и только что загрузил, но получил 500 внутренних ошибок сервера, и я не могу понять причину. Похоже, что он не может видеть некоторые модули, может быть, он не смотрит на мой файл настроек? обратите внимание, конечно. Ниже приведен журнал ошибок для этой проблемы, может быть, это может помочь вам, ребята, что происходит:
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] mod_wsgi (pid=23248): Exception occurred processing WSGI script '/var/www/kaasib/pypr$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] Traceback (most recent call last):
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 24$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] response = self.get_response(request)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 17$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 22$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return debug.technical_500_response(request, *exc_info)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 66, in te$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] html = reporter.get_traceback_html()
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 276, in g$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return t.render(c)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 140, in$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return self._render(context)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return self.nodelist.render(context)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 823, in$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] bit = self.render_node(node, context)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 74, in$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return node.render(context)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 84, in$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] output = self.filter_expression.resolve(context)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 599, in$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] new_obj = func(obj, *arg_vals)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", li$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return format(value, arg)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 310,$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return df.format(format_string)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 33, $
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] pieces.append(force_unicode(getattr(self, piece)()))
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 214,$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return self.format('D, j M Y H:i:s O')
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 33, $
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] pieces.append(force_unicode(getattr(self, piece)()))
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 71, in$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] s = unicode(s)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 121,$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return func(*self.__args, **self.__kw)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py",$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return _trans.ugettext(message)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] return do_translate(message, 'ugettext')
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] _default = translation(settings.LANGUAGE_CODE)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] default_translation = _fetch(settings.LANGUAGE_CODE)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] app = import_module(appname)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, i$
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] __import__(name)
[Sat Dec 29 02:59:37 2012] [error] [client 139.190.233.10] ImportError: No module named company
Вот содержимое файла httpd.conf:
WSGIPythonPath /var/www/kaasib/pyproject/kaasib/
<Directory /var/www/kaasib/pyproject/kaasib/kaasib/>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
Строка WSGISCRIPTAlis находится в файле vhost, доступном на сайте. И следующее содержимое файла wsgi:
"""
WSGI config for kaasib project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kaasib.settings")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
3 ответа
Мне кажется, что ваш проект не находится в вашем pythonpath. Попробуйте добавить это вверху вашего wsgi.py и посмотрите, как оно будет выглядеть:
import os, sys
path = '/path-to/your/project-root/'
if path not in sys.path:
sys.path.append(path)
Было бы полезно увидеть ваш файл apache conf и файл wsgi conf для вашего приложения.
Как вы предположили, похоже, что модуль вашей компании не найден. Это может быть по многим причинам. Я бы начал с проверки вашего WSGIPythonPath и убедитесь, что он включает ваше приложение.
Ознакомьтесь с руководством по развертыванию Django WSGI для получения более подробной информации.
Вы установили модуль на удаленный сервер через pip или каким-либо другим способом? Он просто не может найти имена модулей компании. Также убедитесь, что вы включили модуль "Компания" в установленный файл INSTALLED_APPS в файле настроек.