У меня есть сайт Django и сайт Django CMS, который я обслуживаю с того же сервера Ubuntu 14.04 с MySQL 5.6, Apache2 2.4.7 и Django 1.8 с помощью mod_wsgi версии 4.5.7 с использованием виртуальных хостов. Локально (на моем Linux-ПК) мне удалось добиться этого, работая на обоих сайтах, и, следовательно, решила перейти на сервер.Обслуживание двух сайтов Django с результатами WSGI с ошибкой внутреннего сервера только для одного из сайтов
После миграции, заботясь о том, что все имеет одинаковую версию, ситуация такова, что сайт Django работает правильно, а сайт Django CMS дает мне и внутреннюю ошибку сервера 500. Это мои виртуальные хосты .conf файлы и файл wsgi.py для сломанного сайта.
# wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bsg.settings")
application = get_wsgi_application()
# Django_cms_site.conf
<VirtualHost *:80>
ServerName site.com
ServerAdmin [email protected]
Alias /static/ /home/bsg/cms/static/
Alias /media/ /home/bsg/cms/media/
WSGIScriptAlias//home/bsg/cms/bsg/wsgi.py
WSGIDaemonProcess bsgcms python-path=/home/hicklin/bsg/cms:/home/venv-bsg/lib/python2.7/site-packages
WSGIProcessGroup bsgcms
<Directory /home/bsg/cms>
Require all granted
</Directory>
LogLevel warn
ErrorLog /var/log/apache2/cms-error.log
CustomLog /var/log/apache2/cms-access.log combined
</VirtualHost>
# Django_site.conf
<VirtualHost *:80>
ServerName django.site.com
ServerAdmin [email protected]
Alias /static/ /home/bsg/admin/site/static/
WSGIScriptAlias//home/bsg/admin/site/wsgi.py
WSGIDaemonProcess bsgadmin python-path=/home/bsg/admin:/home/hicklin/venv-bsg/lib/python2.7/site-packages
WSGIProcessGroup bsgadmin
<Directory /home/bsg/admin>
Require all granted
</Directory>
LogLevel warn
ErrorLog /var/log/apache2/admin-error.log
CustomLog /var/log/apache2/admin-access.log combined
</VirtualHost>
Как можно заметить, я использую ту же виртуальную среду для обоих сайтов. Соответствующие журналы дают следующую ошибку.
[Tue Oct 11 22:39:43.416901 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] mod_wsgi (pid=19799): Target WSGI script '/home/bsg/cms/bsg/wsgi.py' cannot be loaded as Python module.
[Tue Oct 11 22:39:43.416942 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] mod_wsgi (pid=19799): Exception occurred processing WSGI script '/home/bsg/cms/bsg/wsgi.py'.
[Tue Oct 11 22:39:43.416977 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] Traceback (most recent call last):
[Tue Oct 11 22:39:43.417014 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] File "/home/bsg/cms/bsg/wsgi.py", line 16, in <module>
[Tue Oct 11 22:39:43.417067 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] application = get_wsgi_application()
[Tue Oct 11 22:39:43.417093 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] File "/home/venv-bsg/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Tue Oct 11 22:39:43.417134 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] django.setup()
[Tue Oct 11 22:39:43.417158 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] File "/home/venv-bsg/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
[Tue Oct 11 22:39:43.417194 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] apps.populate(settings.INSTALLED_APPS)
[Tue Oct 11 22:39:43.417217 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] File "/home/venv-bsg/lib/python2.7/site-packages/django/apps/registry.py", line 78, in populate
[Tue Oct 11 22:39:43.417255 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] raise RuntimeError("populate() isn't reentrant")
[Tue Oct 11 22:39:43.417289 2016] [wsgi:error] [pid 19799] [remote 77.71.226.73:64984] RuntimeError: populate() isn't reentrant
После изменения wsgi.py, чтобы получить реальную ошибку как предложил Дирк Eschler в the thread, ошибка в /var/log/apache2/cms-error.log изменений
[Tue Oct 11 21:36:06.087723 2016] [wsgi:error] [pid 21584] handling WSGI exception
[Tue Oct 11 21:36:06.087811 2016] [wsgi:error] [pid 21584] Traceback (most recent call last):
[Tue Oct 11 21:36:06.087854 2016] [wsgi:error] [pid 21584] File "/home/bsg/cms/bsg/wsgi.py", line 9, in <module>
[Tue Oct 11 21:36:06.087975 2016] [wsgi:error] [pid 21584] application = get_wsgi_application()
[Tue Oct 11 21:36:06.087996 2016] [wsgi:error] [pid 21584] File "/home/venv-bsg/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Tue Oct 11 21:36:06.088067 2016] [wsgi:error] [pid 21584] django.setup()
[Tue Oct 11 21:36:06.088093 2016] [wsgi:error] [pid 21584] File "/home/venv-bsg/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
[Tue Oct 11 21:36:06.088164 2016] [wsgi:error] [pid 21584] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Tue Oct 11 21:36:06.088190 2016] [wsgi:error] [pid 21584] File "/home/venv-bsg/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
[Tue Oct 11 21:36:06.088366 2016] [wsgi:error] [pid 21584] self._setup(name)
[Tue Oct 11 21:36:06.088388 2016] [wsgi:error] [pid 21584] File "/home/venv-bsg/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
[Tue Oct 11 21:36:06.088417 2016] [wsgi:error] [pid 21584] % (desc, ENVIRONMENT_VARIABLE))
[Tue Oct 11 21:36:06.088442 2016] [wsgi:error] [pid 21584] ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
[Tue Oct 11 21:36:08.591950 2016] [wsgi:error] [pid 21584] [remote 77.71.226.73:3851] mod_wsgi (pid=21584): Target WSGI script '/home/bsg/cms/bsg/wsgi.py' does not contain WSGI application 'application'.
Обратите внимание, что мне удалось запустить, получить доступ и работать на сайте cms с помощью python manage.py runningerver, и он работает без сбоев. После последней ошибки ничего еще не принесло. Любая помощь или намеки приветствуются.
Извините за поздний ответ. Потребовалось некоторое время, чтобы найти решение для этого. Во-первых, я хотел бы поблагодарить вас за ваш быстрый ответ. –