【发布时间】:2014-09-24 13:32:25
【问题描述】:
我在 Elastic Beanstalk 上成功部署了我的 Django (1.7),但是当我在浏览器中加载它时得到 500。在日志中我发现:
[Wed Sep 24 12:56:11.434509 2014] [:error] [pid 27030] [remote 172.31.6.176:0] mod_wsgi (pid=27030): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Wed Sep 24 12:56:11.434557 2014] [:error] [pid 27030] [remote 172.31.6.176:0] mod_wsgi (pid=27030): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Wed Sep 24 12:56:11.434596 2014] [:error] [pid 27030] [remote 172.31.6.176:0] Traceback (most recent call last):
[Wed Sep 24 12:56:11.434636 2014] [:error] [pid 27030] [remote 172.31.6.176:0] File "/opt/python/current/app/mysite/wsgi.py", line 14, in <module>
[Wed Sep 24 12:56:11.434698 2014] [:error] [pid 27030] [remote 172.31.6.176:0] application = get_wsgi_application()
[Wed Sep 24 12:56:11.434721 2014] [:error] [pid 27030] [remote 172.31.6.176:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Sep 24 12:56:11.434759 2014] [:error] [pid 27030] [remote 172.31.6.176:0] django.setup()
[Wed Sep 24 12:56:11.434781 2014] [:error] [pid 27030] [remote 172.31.6.176:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 20, in setup
[Wed Sep 24 12:56:11.434813 2014] [:error] [pid 27030] [remote 172.31.6.176:0] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Wed Sep 24 12:56:11.434835 2014] [:error] [pid 27030] [remote 172.31.6.176:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in __getattr__
[Wed Sep 24 12:56:11.434867 2014] [:error] [pid 27030] [remote 172.31.6.176:0] self._setup(name)
[Wed Sep 24 12:56:11.434886 2014] [:error] [pid 27030] [remote 172.31.6.176:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 40, in _setup
[Wed Sep 24 12:56:11.434916 2014] [:error] [pid 27030] [remote 172.31.6.176:0] % (desc, ENVIRONMENT_VARIABLE))
[Wed Sep 24 12:56:11.435013 2014] [:error] [pid 27030] [remote 172.31.6.176:0] 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.
我正在像这样在我的 .ebextension mysite.config 文件中设置设置文件。
- option_name: DJANGO_SETTINGS_MODULE
value: "mysite.settings"
我也在大多数文件中添加了这个:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
问题在于我的设置文件应该是什么样子。我已经用谷歌搜索了好几个小时,但我无法让它工作......我什至不确定我的设置文件应该是什么样子。现在它看起来像这样:
LOGGING_CONFIG = 'django.utils.log.dictConfig'
我很确定问题出在设置文件上。如果有人能指出我正确的方向,我将不胜感激。
【问题讨论】:
标签: django amazon amazon-elastic-beanstalk