gpt4 book ai didi

python - Django 应用程序未在 Elastic Beanstalk AWS 上启动

转载 作者:行者123 更新时间:2023-11-28 19:03:43 24 4
gpt4 key购买 nike

当我在弹性 beanstalk 上部署我的 Django 项目时,我收到 500 内部服务器错误。我已经尝试了一切,EB 仪表板看起来还不错,健康状况良好,没有提到其中的任何错误。任何人都可以阐明这一点吗?

============= i-03980c0f6a1094e3c ==============
-------------------------------------
/var/log/httpd/error_log
-------------------------------------
[Wed Apr 04 13:15:51.669498 2018] [suexec:notice] [pid 3065] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Apr 04 13:15:51.684578 2018] [http2:warn] [pid 3065] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the
currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Wed Apr 04 13:15:51.684588 2018] [http2:warn] [pid 3065] AH02951: mod_ssl does not seem to be enabled
[Wed Apr 04 13:15:51.685042 2018] [lbmethod_heartbeat:notice] [pid 3065] AH02282: No slotmem from mod_heartmonitor
[Wed Apr 04 13:15:51.686951 2018] [mpm_prefork:notice] [pid 3065] AH00163: Apache/2.4.27 (Amazon) mod_wsgi/3.5 Python/3.6.2 configured -- resuming normal operations
[Wed Apr 04 13:15:51.686971 2018] [core:notice] [pid 3065] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Apr 04 13:16:13.037691 2018] [mpm_prefork:notice] [pid 3065] AH00169: caught SIGTERM, shutting down
[Wed Apr 04 13:16:14.092208 2018] [suexec:notice] [pid 3287] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Apr 04 13:16:14.107856 2018] [so:warn] [pid 3287] AH01574: module wsgi_module is already loaded, skipping
[Wed Apr 04 13:16:14.110001 2018] [http2:warn] [pid 3287] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the
currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Wed Apr 04 13:16:14.110011 2018] [http2:warn] [pid 3287] AH02951: mod_ssl does not seem to be enabled
[Wed Apr 04 13:16:14.110578 2018] [lbmethod_heartbeat:notice] [pid 3287] AH02282: No slotmem from mod_heartmonitor
[Wed Apr 04 13:16:14.113943 2018] [mpm_prefork:notice] [pid 3287] AH00163: Apache/2.4.27 (Amazon) mod_wsgi/3.5 Python/3.6.2 configured -- resuming normal operations
[Wed Apr 04 13:16:14.113964 2018] [core:notice] [pid 3287] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed Apr 04 13:16:14.142312 2018] [:error] [pid 3292] mod_wsgi (pid=3292): Call to 'site.addsitedir()' failed for '(null)', stopping.
[Wed Apr 04 13:16:14.142341 2018] [:error] [pid 3292] mod_wsgi (pid=3292): Call to 'site.addsitedir()' failed for '/opt/python/run/venv/lib64/python3.6/site-packages:/opt/python/run/venv/lib/python3.6/site-packages'.
[Wed Apr 04 13:16:16.869762 2018] [:error] [pid 3292] mod_wsgi (pid=3292): Call to 'site.addsitedir()' failed for '(null)', stopping.
[Wed Apr 04 13:16:16.869800 2018] [:error] [pid 3292] mod_wsgi (pid=3292): Call to 'site.addsitedir()' failed for '/opt/python/run/venv/lib64/python3.6/site-packages:/opt/python/run/venv/lib/python3.6/site-packages'.
[Wed Apr 04 13:16:16.870482 2018] [:error] [pid 3292] [remote 127.0.0.1:252] mod_wsgi (pid=3292): Target WSGI script '/opt/python/current/app/testapi/wsgi.py' cannot be loaded as Python module.
[Wed Apr 04 13:16:16.870510 2018] [:error] [pid 3292] [remote 127.0.0.1:252] mod_wsgi (pid=3292): Exception occurred processing WSGI script '/opt/python/current/app/testapi/wsgi.py'.
[Wed Apr 04 13:16:16.870676 2018] [:error] [pid 3292] [remote 127.0.0.1:252] Traceback (most recent call last):
[Wed Apr 04 13:16:16.870699 2018] [:error] [pid 3292] [remote 127.0.0.1:252] File "/opt/python/current/app/testapi/wsgi.py", line 12, in <module>
[Wed Apr 04 13:16:16.870702 2018] [:error] [pid 3292] [remote 127.0.0.1:252] from django.core.wsgi import get_wsgi_application
[Wed Apr 04 13:16:16.870716 2018] [:error] [pid 3292] [remote 127.0.0.1:252] ModuleNotFoundError: No module named 'django'
[Wed Apr 04 13:16:17.873718 2018] [:error] [pid 3292] [remote 127.0.0.1:248] mod_wsgi (pid=3292): Target WSGI script '/opt/python/current/app/testapi/wsgi.py' cannot be loaded as Python module.
[Wed Apr 04 13:16:17.873768 2018] [:error] [pid 3292] [remote 127.0.0.1:248] mod_wsgi (pid=3292): Exception occurred processing WSGI script '/opt/python/current/app/testapi/wsgi.py'.
[Wed Apr 04 13:16:17.873855 2018] [:error] [pid 3292] [remote 127.0.0.1:248] Traceback (most recent call last):
[Wed Apr 04 13:16:17.873881 2018] [:error] [pid 3292] [remote 127.0.0.1:248] File "/opt/python/current/app/testapi/wsgi.py", line 12, in <module>
[Wed Apr 04 13:16:17.873885 2018] [:error] [pid 3292] [remote 127.0.0.1:248] from django.core.wsgi import get_wsgi_application
[Wed Apr 04 13:16:17.873899 2018] [:error] [pid 3292] [remote 127.0.0.1:248] ModuleNotFoundError: No module named 'django'
[Wed Apr 04 13:16:18.876808 2018] [:error] [pid 3292] [remote 127.0.0.1:2556] mod_wsgi (pid=3292): Target WSGI script '/opt/python/current/app/testapi/wsgi.py' cannot be loaded as Python module.
[Wed Apr 04 13:16:18.876857 2018] [:error] [pid 3292] [remote 127.0.0.1:2556] mod_wsgi (pid=3292): Exception occurred processing WSGI script '/opt/python/current/app/testapi/wsgi.py'.
[Wed Apr 04 13:16:18.876927 2018] [:error] [pid 3292] [remote 127.0.0.1:2556] Traceback (most recent call last):

最佳答案

在您的项目目录中,您应该有一个.elasticbeanstalk 文件夹,您还必须有另一个.ebextensions。如果没有,请添加。

然后您必须创建文件以在 EBT 将为您触发的实例上运行一些东西。例如,添加一个类似 10_packages.config 的文件,数字很重要,因为它将保持顺序。文件内容是这样的:

# 10_packages.config
# Add the packages needed to run the application and some other tools
packages:
yum:
git: []
postgresql94-devel: []
gcc: []
gcc-c++: []
make: []
libffi-devel: []
libmemcached-devel: []
vim-enhanced: []

然后您需要安装 django 和您的应用程序所需的所有包。创建一个名为 20_pip_requirements.config

的文件
# 20_pip_requirements.config
# Update pip in the venv
commands:
01_upgrade_pip_for_venv:
command: "sudo /opt/python/run/venv/bin/pip install --upgrade pip"

最终,您必须迁移数据库,这必须只运行一次。让我们启动另一个文件 30_migrate.config

# 30_migrate.config
container_commands:
01_migrate_database:
command: "./manage.py migrate"
leader_only: true

这只是一个示例,但可以让您了解必须执行的操作。

阅读docs了解更多信息。

关于python - Django 应用程序未在 Elastic Beanstalk AWS 上启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49652460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com