我严格遵循AWS官方指南,将Django应用部署到用于学校项目的Elastic Beanstalk(https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html)。它在本地运行,但是当我尝试部署它时会显示500错误消息。我在代码中进行了许多调整,但这些调整似乎无效。 AWS仪表板显示一个警告,指出:环境运行状况已从“确定”转换为“警告”。 100%的请求使用HTTP 5xx失败。可能是我目前在欧洲的时区问题?
我试图将调试模式从true更改为false,但是我不认为这是问题所在。我真的不明白为什么它不起作用,我从没有在终端执行中出错,并且总是正确地部署了所有东西。由于某种原因,它只是不显示网页。
MacBook-Air-di-Davide:ebdjango davidemerlin$ eb create django-env
Creating application version archive "app-190718_165248".
Uploading ebdjango/app-190718_165248.zip to S3. This may take a while.
Upload Complete.
Environment details for: django-env
Application name: ebdjango
Region: eu-central-1
Deployed Version: app-190718_165248
Environment ID: e-3mxbcch2rm
Platform: arn:aws:elasticbeanstalk:eu-central-1::platform/Python 3.6 running on 64bit Amazon Linux/2.8.6
Tier: WebServer-Standard-1.0
CNAME: UNKNOWN
Updated: 2019-07-18 14:52:51.893000+00:00
Printing Status:
2019-07-18 14:52:51 INFO createEnvironment is starting.
2019-07-18 14:52:52 INFO Using elasticbeanstalk-eu-central-1-725098113628 as Amazon S3 storage bucket for environment data.
2019-07-18 14:53:16 INFO Created security group named: sg-0d5da9ecf4206ab11
2019-07-18 14:53:32 INFO Created load balancer named: awseb-e-3-AWSEBLoa-GCK3W368WNAW
2019-07-18 14:53:32 INFO Created security group named: awseb-e-3mxbcch2rm-stack-AWSEBSecurityGroup-10HEII5KA2YFV
2019-07-18 14:53:32 INFO Created Auto Scaling launch configuration named: awseb-e-3mxbcch2rm-stack-AWSEBAutoScalingLaunchConfiguration-16YCNNVJS4QJG
-- Events -- (safe to Ctrl+C)
eb status
Environment details for: django-env
Application name: ebdjango
Region: eu-central-1
Deployed Version: None
Environment ID: e-3mxbcch2rm
Platform: arn:aws:elasticbeanstalk:eu-central-1::platform/Python 3.6 running on 64bit Amazon Linux/2.8.6
Tier: WebServer-Standard-1.0
CNAME: django-env.q7fdcfwnii.eu-central-1.elasticbeanstalk.com
Updated: 2019-07-18 14:53:32.535000+00:00
Status: Launching
Health: Grey
Alert: An update to the EB CLI is available. Run "pip install --upgrade awsebcli" to get the latest version.
(base) MacBook-Air-di-Davide:ebdjango davidemerlin$ eb deploy
Creating application version archive "app-190718_165726".
Uploading ebdjango/app-190718_165726.zip to S3. This may take a while.
Upload Complete.
2019-07-18 14:57:28 INFO Environment update is starting.
2019-07-18 14:57:31 INFO Deploying new version to instance(s).
2019-07-18 14:57:53 INFO New application version was deployed to running EC2 instances.
2019-07-18 14:57:53 INFO Environment update completed successfully.
Alert: An update to the EB CLI is available. Run "pip install --upgrade awsebcli" to get the latest version.
(base) MacBook-Air-di-Davide:ebdjango davidemerlin$ eb open'''
I expect to load the page at django-env.q7fdcfwnii.eu-central-1.elasticbeanstalk.com
答案 0 :(得分:1)
您解决了吗?我奋力挣扎了数周,但在严格按照说明操作后却遇到了502。
然后我发现了此post,并推断出它是错字或过时的指令(*/wsgi.py
应该是*.wsgi:application
)。
为AWS文档创建了pull request,并自此进行了更新。
答案 1 :(得分:0)
我遇到了同样的问题,直到意识到我没有在settings.py文件中包含以下行:
ALLOWED_HOSTS = ['eb-django-app-dev.elasticbeanstalk.com']
按照本教程的第5步所述,用我自己的自定义应用程序链接替换括号内的链接。
保存文件并提交后,我摆脱了500错误。
答案 2 :(得分:0)
我试图通过遵循this documentation将Django Rest Api部署到Beanstalk。而且我遇到了相同的状态码500 错误。
我通过进行以下两项更改来解决了这个问题:
AWS Beanstalk的python 3.6环境似乎不适用于最新的Django 版本。因此,我使用此命令创建了一个新的 python 3.7 环境。
eb init -p python-3.7 django-tutorial
将 WSGI路径更改为:
WSGIPath:YourDjangoProjectFolder.wsgi:application
所有其他内容与该文档中所述相同。