繁体   English   中英

使用AWS Elasticbeanstalk部署Django App时出现WSGIPath错误

[英]WSGIPath Error while Deploying Django App using AWS Elasticbeanstalk

我正在尝试使用Elastic Beanstalks在AWS上部署Django项目。 我已经尝试了WSGIPath的多个值更改。 但是每次,我都会遇到相同的错误:

从ubuntu终端运行“ eb create”时:

错误日志(来自Eb日志):

-------------------------------------
/var/log/httpd/error_log
-------------------------------------
mod_wsgi (pid=3005): Target WSGI script '/opt/python/current/app/myapp/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=3005): Exception occurred processing WSGI script '/opt/python/current/app/myapp/wsgi.py'.
Traceback (most recent call last):
    File "/opt/python/current/app/myapp/wsgi.py", line 24, 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()
   File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
   File "/opt/python/run/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 55, in __getattr__
     self._setup(name)
   File "/opt/python/run/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 43, in _setup

有人可以解释一下如何选择此路径以及如何对其进行纠正吗?

我的项目结构:

.
├── .ebextensions
│   ├── myapp.config
├── .elasticbeanstalk
│   ├── config.yml
├── db.sqlite3
├── manage.py
├── media
├── abc
│   ├── admin.py
│   ├── apps.py
│   ├── constants.py
│   ├── __init__.py
│   │   └── __init__.py
│   ├── models.py
│   ├── test1_form.py
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── requirements.txt
├── static
├── templates
└── myapp
    ├── constants.py
    ├── test1_form.py
    ├── __init__.py
    ├── registration_form.py
    ├── settings.py
    ├── urls.py
    ├── views.py
    └── wsgi.py

myapp.config文件:

option_settings:
        "aws:elasticbeanstalk:container:python": 
        WSGIPath: "myapp/wsgi.py"

config.yml文件

branch-defaults:
  master:
    environment: abc-dev
    group_suffix: null
global:
  application_name: abc
  default_ec2_keyname: abc_eb_key
  default_platform: Python 2.7
  default_region: us-east-1
  profile: eb-cli
  sc: git

settings.py文件:

WSGI_APPLICATION = 'myapp.wsgi.application'

myapp / wsgi.py文件:

import os, sys, inspect

from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")

application = get_wsgi_application()

更新了myapp.config文件,该文件有效:

option_settings:
  "aws:elasticbeanstalk:container:python": 
    WSGIPath: "myapp/wsgi.py"
  "aws:elasticbeanstalk:container:python:staticfiles":
    "/static/": "static/"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM