目标WSGI脚本WSGI.py';无法作为Python模块加载
我试图用AWS ElasticBeanstalk扩展我的django项目,但是我得到了一个错误,当我部署项目时,错误没有出现,但是当我扩展它时,我得到了这个错误:目标WSGI脚本WSGI.py';无法作为Python模块加载,python,django,amazon-elastic-beanstalk,uwsgi,wsgi,Python,Django,Amazon Elastic Beanstalk,Uwsgi,Wsgi,我试图用AWS ElasticBeanstalk扩展我的django项目,但是我得到了一个错误,当我部署项目时,错误没有出现,但是当我扩展它时,我得到了这个错误: ValueError: Unable to configure handler 'file_log': [Errno 13] Permission denied: '/var/log/meatme/django.log' mod_wsgi (pid=4829): Target WSGI script '/op
ValueError: Unable to configure handler 'file_log': [Errno 13] Permission
denied: '/var/log/meatme/django.log'
mod_wsgi (pid=4829): Target WSGI script
'/opt/python/current/app/meatme/meatme/wsgi.py' cannot be loaded as
Python module.
mod_wsgi (pid=4829): Exception occurred processing WSGI script
'/opt/python/current/app/meatme/meatme/wsgi.py'.
Traceback (most recent call last):
File "/opt/python/current/app/meatme/meatme/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/opt/python/run/venv/lib/python2.7/site-
packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py",
line 22, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/opt/python/run/venv/lib/python2.7/site-
packages/django/utils/log.py", line 75, in configure_logging
logging_config_func(logging_settings)
File "/usr/lib64/python2.7/logging/config.py", line 794, in dictConfig
dictConfigClass(config).configure()
File "/usr/lib64/python2.7/logging/config.py", line 576, in configure
'%r: %s' % (name, e))
和wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "meatme.settings")
application = get_wsgi_application()
当我执行eb deploy时,它工作得很好,但是当我执行eb clone 2(测试规模)时,新实例不工作。在mod_wsgi下运行时,应该避免使用单独的文件设置Python日志记录。相反,只需将其配置为将日志发送到控制台流。然后,这些消息将被捕获到Apache错误日志中 使用:
假设您在标记问题时是指mod_wsgi而不是uWSGI。问题标题中的错误消息似乎来自mod_wsgi,而不是uWSGI。
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "meatme.settings")
application = get_wsgi_application()
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
},
}