在线尝试了多种解决方案,但无法正常运行! 基本上,我的应用程序已部署,但http响应是“内部服务器错误”。 在调查EB日志时,我发现了以下回溯。
[Sat Jun 08 10:28:56.880823 2019] [:error] [pid 4776] [remote 172.31.4.251:180] Traceback (most recent call last):
[Sat Jun 08 10:28:56.880846 2019] [:error] [pid 4776] [remote 172.31.4.251:180] File "/opt/python/current/app/modelforms/modelforms/wsgi.py", line 12, in <module>
[Sat Jun 08 10:28:56.880863 2019] [:error] [pid 4776] [remote 172.31.4.251:180] from django.core.wsgi import get_wsgi_application
[Sat Jun 08 10:28:56.880878 2019] [:error] [pid 4776] [remote 172.31.4.251:180] ModuleNotFoundError: No module named 'django'
[Sat Jun 08 10:29:10.828039 2019] [:error] [pid 4776] [remote 172.31.42.54:180] mod_wsgi (pid=4776): Target WSGI script '/opt/python/current/app/modelforms/modelforms/wsgi.py' cannot be loaded as Python module.
[Sat Jun 08 10:29:10.828089 2019] [:error] [pid 4776] [remote 172.31.42.54:180] mod_wsgi (pid=4776): Exception occurred processing WSGI script '/opt/python/current/app/modelforms/modelforms/wsgi.py'.
我的requirements.txt放置在所有目录中,但是django模块无法识别。似乎它没有首先安装。 该文件的内容为:
Django==2.2.1
Pillow==6.0.0
pytz==2019.1
sorl-thumbnail==12.5.0
sqlparse==0.3.0
感谢您的帮助。
EDIT1: 我没有ebextentions设置,但是当我运行“ eb config”时,存在相同的配置
aws:elasticbeanstalk:container:python:
NumProcesses: '1'
NumThreads: '15'
StaticFiles: /static/=static/
WSGIPath: modelforms/modelforms/wsgi.py
aws:elasticbeanstalk:container:python:staticfiles:
/static/: static/
aws:elasticbeanstalk:environment:
EnvironmentType: LoadBalanced
ExternalExtensionsS3Bucket: null
ExternalExtensionsS3Key: null
LoadBalancerType: application
ServiceRole: aws-elasticbeanstalk-service-role
答案 0 :(得分:0)
尝试将DJANGO_SETTINGS_MODULE和PYTHONPATH添加到配置中
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "modelforms.settings"
"PYTHONPATH": "/opt/python/current/app/modelforms:$PYTHONPATH"
还要检查运行状况仪表板,并确保它在测试之前显示为已部署