我正在尝试将Django网站部署到Elastic Beanstalk,但始终出现500错误。我在系统上使用的是Python 3.5,但是Elastic Beanstalk仅允许您选择3.4或3.6,因此我选择了3.4,不确定是否是问题的一部分。另外,我通过SSH进入我的EC2,并执行了“ sudo pip install psycopg2”操作,但这也不起作用。
这是我的错误消息的摘要。它始终指出psycopg2未加载,并且WSGI无法作为目标模块加载。
<body>
<div id="object1">10</div>
<div id="object2">10</div>
<div id="object3">10</div>
<div id="object4">10</div>
<div id="extra1"></div>
<div id="extra2"></div>
<div id="extra3"></div>
<div id="extra4"></div>
<script>
function changeHTML1() {
var ob1 = document.getElementById("object1");
var ex1 = document.getElementById("extra1");
if (ob1.innerHTML == "10") {
ex1.innerHTML = "D5";
}
if (ob1.innerHTML == "9") {
ex1.innerHTML = "1-D4";
}
if (ob1.innerHTML == "8") {
ex1.innerHTML = "D4";
}
}
function changeHTML2() {
var ob2 = document.getElementById("object2");
var ex2 = document.getElementById("extra2");
if (ob2.innerHTML == "10") {
ex2.innerHTML = "D5";
}
if (ob2.innerHTML == "9") {
ex2.innerHTML = "1-D4";
}
if (ob2.innerHTML == "8") {
ex2.innerHTML = "D4";
}
}
function changeHTML3() {
var ob3 = document.getElementById("object3");
var ex3 = document.getElementById("extra3");
if (ob3.innerHTML == "10") {
ex3.innerHTML = "D5";
}
if (ob3.innerHTML == "9") {
ex3.innerHTML = "1-D4";
}
if (ob3.innerHTML == "8") {
ex3.innerHTML = "D4";
}
}
function changeHTML4() {
var ob4 = document.getElementById("object4");
var ex4 = document.getElementById("extra4");
if (ob4.innerHTML == "10") {
ex4.innerHTML = "D5";
}
if (ob4.innerHTML == "9") {
ex4.innerHTML = "1-D4";
}
if (ob4.innerHTML == "8") {
ex4.innerHTML = "D4";
}
}
</script>
</body>
这是我的python.config:
-------------------------------------
/var/log/httpd/error_log
-------------------------------------
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'
mod_wsgi (pid=3251): Target WSGI script '/opt/python/current/app/omnibus/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=3251): Exception occurred processing WSGI script '/opt/python/current/app/omnibus/wsgi.py'.
Traceback (most recent call last):
File "/opt/python/current/app/omnibus/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
django.setup(set_prefix=False)
这是我的settings.py中的摘录:
--------------
python.config
--------------
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "omnibus.settings"
PYTHONPATH: "./omnibus"
"aws:elasticbeanstalk:container:python":
WSGIPath: "omnibus/wsgi.py"
StaticFiles: "/static/=www/static/"
packages:
yum:
postgresql95-devel: []
container_commands:
01_migrate:
command: "python manage.py migrate"
leader_only: true
02_collectstatic:
command: "python manage.py collectstatic --noinput"
请有人帮我部署我的网站!!我将永远感激你!