如何解决将现有Django应用程序部署到Elastic Beanstalk时出现的错误? “您的WSGIPath引用的文件不存在”

时间:2019-04-16 01:14:43

标签: django amazon-elastic-beanstalk

概述

我在计算机上构建了一个Django应用程序,该计算机使用以下命令在本地运行:python manage.py runserver

我想将其部署到AWS Elastic Beanstalk以使其公开可见。我使用pip安装了eb cli并运行了eb init 并配置了我的所有设置。

当我压缩并手动将代码上传到AWS环境时,遇到关于我的wsgi.py文件的错误:

Your WSGIPath refers to a file that does not exist.

我已经在SO上查看了其他问题,并查看了我的项目结构(见下文),.gitignore.ebignore文件,我重新启动了环境并尝试了各种wsgi.py文件的路径。

项目结构

fresh_air/ ------------------> This is the folder that I zip up
\ -- .ebextensions
     \ -- django.config
\ -- .elasticbeanstalk
     \ -- config.yml
\ -- some other auxiliary apps that assist the main app
\ -- fresh_air/ --------------> My main app
     \ -- static/
     \ -- __init__.py
     \ -- settings.py
     \ -- urls.py
     \ -- views.py
     \ -- wsgi.py 
\ -- .ebignore (empty file, just there to overwrite .gitignore)
\ -- .gitignore
\ -- manage.py
\ -- requirements.txt

django.config

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: fresh_air/wsgi.py

config.yml

branch-defaults:
  default:
    environment: FreshAir-env
environment-defaults:
  FreshAir-env:
    branch: null
    repository: null
global:
  application_name: fresh-air
  default_ec2_keyname: null
  default_platform: arn:aws:elasticbeanstalk:us-west-2::platform/Python 3.6 running
    on 64bit Amazon Linux/2.8.2
  default_region: us-west-2
  include_git_submodules: true
  instance_profile: null
  platform_name: null
  platform_version: null
  profile: eb-cli
  sc: null
  workspace_type: Application

wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fresh_air.settings')

application = get_wsgi_application()

Elastic Beanstalk error logs

我希望WSGIPath中提供的django.config是正确的,并且可以直接进入wsgi.py,但似乎并非如此。我先构建Django应用程序,然后尝试使其与Elastic Beanstalk兼容,这可能是一个问题吗?

0 个答案:

没有答案