我正在尝试使用Elastic Beanstalks在AWS上部署我的Django项目。我正在关注此链接进行部署:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html。
文件夹结构:
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "abc.settings"
PYTHONPATH: "./project:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: "project/abc/wsgi.py"
文件:.ebextensions / 01-project.config [更新]:
branch-defaults:
default:
environment: project-dev
group_suffix: null
global:
application_name: project
default_ec2_keyname: project_ec2_key
default_platform: Python 3.4
default_region: us-east-1
profile: eb-cli
sc: null
文件:.elasticbeanstalk / config.yml
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "abc.settings")
application = get_wsgi_application()
文件wsgi.py:
-------------------------------------
/var/log/httpd/error_log
-------------------------------------
[remote xx.xx.xx.xx:0] ImportError: No module named 'abc'
[remote xx.xx.xx.xx:0] mod_wsgi (pid=2857): Target WSGI script '/opt/python/current/app/project/abc/wsgi.py' cannot be loaded as Python module.
[remote xx.xx.xx.xx:0] mod_wsgi (pid=2857): Exception occurred processing WSGI script '/opt/python/current/app/project/abc/wsgi.py'.
[remote xx.x.xx.xx:0] Traceback (most recent call last):
[remote xx.xx.xx.xx:0] File "/opt/python/current/app/project/abc/wsgi.py", line 16, in <module>
[remote xx.xx.xx.xx:0] application = get_wsgi_application()
[remote xx.xx.xx.xx:0] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[remote xx.xx.xx.xx:0] django.setup()
[remote xx.xx.xx.xx:0] File "/opt/python/run/venv/lib/python3.4/site-packages/django/__init__.py", line 17, in setup
[remote xx.xx.xx.xx:0] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[remote xx.xx.xx.xx:0] File "/opt/python/run/venv/lib/python3.4/site-packages/django/conf/__init__.py", line 55, in __getattr__
[remote xx.xx.xx.xx:0] self._setup(name)
[remote xx.xx.xx.xx:0] File "/opt/python/run/venv/lib/python3.4/site-packages/django/conf/__init__.py", line 43, in _setup
[remote xx.xx.xx.xx:0] self._wrapped = Settings(settings_module)
命令:
1)&#39; eb create&#39;
信息:成功启动环境:
2)eb open
内部服务器错误(在浏览器上)
日志:(运行:eb logs&gt; logs.txt)
public class doscmd {
public static void main(String args[]) {
try {
Process p = Runtime.getRuntime().exec("cmd /C dir");
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = reader.readLine();
while (line != null) {
System.out.println(line);
line = reader.readLine();
}
} catch (IOException e1) {
} catch (InterruptedException e2) {
}
System.out.println("Done");
}
}
有人可以建议如何解决此问题吗?
谢谢,
答案 0 :(得分:0)
你试过这个吗
import os, sys
sys.path.append('path/to/abc')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "abc.settings")
application = get_wsgi_application()
更改ebextensions / 01-project.config:
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "abc.settings"
PYTHONPATH: "./project:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: "project/abc/wsgi.py"
我认为最好把完整的路径作为&#34; PYTHONPATH&#34;
答案 1 :(得分:0)
刚改变
PYTHONPATH: "./project/abc:$PYTHONPATH"
到
PYTHONPATH: "./project:$PYTHONPATH"
在.ebextensions / 01-project.config文件中,它工作正常。 :)
答案 2 :(得分:-1)
确保settings.py文件中存在INSTALLED_APPS = "abc"