概述
我在计算机上构建了一个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()
我希望WSGIPath
中提供的django.config
是正确的,并且可以直接进入wsgi.py,但似乎并非如此。我先构建Django应用程序,然后尝试使其与Elastic Beanstalk兼容,这可能是一个问题吗?