【发布时间】:2023-04-09 06:04:01
【问题描述】:
我正在尝试使用 Elastic Beanstalks 在 AWS 上部署我的 Django 项目。我正在关注此链接进行部署:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html。
文件夹结构:
Project
├── logs.txt
├── requirements.txt
└── project
├── db.sqlite3
├── manage.py
├── miscellaneousConfig
├── README.md
├── static
│ ├── css
│ ├── img
│ ├── js
├── abc1
│ ├── admin.py
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── templates
│ │ ├── file1.html
│ │ └── file2.html
│ ├── tests.py
│ ├── urls.py
│ └── views.py
└── abc
├── functions.py
├── __init__.py
├── settings.py
├── urls.py
├── views.py
└── wsgi.py
文件:.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"
文件:.elasticbeanstalk/config.yml
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
文件wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "abc.settings")
application = get_wsgi_application()
命令:
1) 'eb 创建'
INFO:成功启动环境:
2) 电子打开
内部服务器错误(在浏览器上)
日志:(通过运行:eb logs > logs.txt)
-------------------------------------
/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)
有人可以建议如何解决这个问题吗?
谢谢,
【问题讨论】:
-
@Baterson 请提供您的意见。自 3 天以来一直坚持这一点。
-
你的
reqiurements.txt是什么样的?
标签: python django amazon-web-services amazon-ec2 amazon-elastic-beanstalk