2017-10-20 122 views
0

我試圖用AWS ElasticBeanstalk來擴展我的django項目,但是我得到一個錯誤,當我部署該項目時錯誤不會出現,但是當我縮放但我得到這個錯誤:目標WSGI腳本wsgi.py'不能作爲Python模塊加載

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)) 

我有這個配置文件.ebextensions:

commands: 
    00_create_dir: 
    command: mkdir -p /var/log/meatme 
    01_change_permissions: 
    command: chmod g+s /var/log/meatme 
    02_change_owner: 
    command: chown -R wsgi:wsgi /var/log/meatme 

和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部署它的工作完美,但當我做eb克隆2(測試規模)新實例不工作。

+0

假設你的意思是mod_wsgi的,而不是uWSGI爲您所標記的問題。問題標題中的錯誤消息看起來是來自mod_wsgi而不是uWSGI。 –

回答

1

在mod_wsgi下運行時,應避免使用單獨的文件設置Python日誌記錄。相反,只需將其配置爲將日誌記錄發送到控制檯流。這些消息將在Apache錯誤日誌中被捕獲。

用途:

LOGGING = { 
    'version': 1, 
    'disable_existing_loggers': False, 
    'handlers': { 
     'console': { 
      'class': 'logging.StreamHandler', 
     }, 
    }, 
    'loggers': { 
     'django': { 
      'handlers': ['console'], 
      'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'), 
     }, 
    }, 
} 
相關問題