我严格按照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
我遇到了同样的问题,直到意识到我没有在settings.py文件中包含以下行:
ALLOWED_HOSTS = ['eb-django-app-dev.elasticbeanstalk.com']
将括号内的链接替换为我自己的自定义应用程序链接,如教程的第5步所述。
保存文件并提交后,我摆脱了500错误。
希望它也对您有用。