在AWS上设置Django弹性Beanstalk:找不到WSGIPath [英] Setting up Django on AWS Elastic Beanstalk: WSGIPath not found
问题描述
错误 - 您的WSGIPath是指不存在的文件。
我按照教程这里,一切顺利,直到第6步结束,但我不能为了生命中的任何东西显示除了通用的弹性豆串第5页#2的页面。当我运行
./ manage.py runserver
在我的本地机器上,一切正常应用,但我无法让该页面部署。我第一次尝试用自己写的一个小Django网站。它没有工作,所以我删除了我所做的一切,再次尝试,没有工作,所以我删除了所有,并尝试再次使用一个新的django安装。我尝试了一大堆小东西,但我想我错过了一些重要的事情。
我添加了一个python.config文件,如本教程。
这是我的文件结构:
- 。git /
-.mysite /
-myapp /
-__init__.py
-models.py
-tests.py
-views.py
- mysite /
-__init__.py
-settings.py
-urls.py
-wsgi.py
-.ebextensions /
-python.config
-manage.py
-mysite.db
-requirements.txt
从我的settings.py:
DATABASES = {
'default':{
' ENGINE':'django.db.backends.sqlite3',
'NAME':'mysite.db',
'USER':'',
'PASSWORD':'',
'HOST':'',
'PORT':'',
}
}
这里是python.config:
container_commands:01_syncdb:
command: django-admin.py syncdb --noinput
leader_only:true
option_settings:
- 命名空间:aws:elasticbeanstalk:container:python
option_name:WSGIPath
value:mysite / wsgi.py
- option_name:DJANGO_SETTINGS_MODULE
值:mysite.settings
- option_name:AWS_SECRET_KEY
值:<这是我的秘密密钥>
- option_name:AWS_ACCESS_KEY_ID
值:<这是我的访问密钥>
是否有另一个地方需要定义我的WSGIPath?有没有办法通过AWS控制台?我应该直接跳过EB,直接使用EC2吗?
从 https://forums.aws.amazon.com/thread.jspa?messageID=396656񠵰
.ebextensions目录必须位于应用程序的根级别目录中,但是从日志输出中,目录位于mysite / .ebextensions目录中。所以例如,当您运行git aws.push后,在文档中遵循django教程后,您的根目录将如下所示:
。
├──.ebextensions
│└──python.config
├──。弹性豆串
│├──配置
├──.git
├──gitignore
├──manage.py
├──mysite
│├──__init__.py
│├──settings.py
│├──urls.py
│└──wsgi.py
└──requirements.txt
而不是这样:
。
└──mysite
├──.ebextensions
├──弹性豆串
├──.git
├──.gitignore
├─ ─manage.py
├──mysite
└──requirements.txt
I've been trying for several days now to set up Django under Amazon Web Services' Elastic Beanstalk. I think the problem I'm hitting is this one:
ERROR - Your WSGIPath refers to a file that does not exist.
I followed the tutorial here and all goes well until the end of Step 6, but I can't for the life of me get anything to display other than the generic Elastic Beanstalk page from Step 5, #2. When I run
./manage.py runserver
on my local machine, everything works as it should, but I can't get that page to deploy. I first tried with a small Django site I wrote myself. It didn't work, so I deleted everything I'd done and tried again, that didn't work, so I deleted all that and tried again with a fresh django install. I tried that a bunch of times fiddling with little things, but I think I'm missing something major.
I added a python.config file as described in this tutorial.
Here's my file structure:
-.git/
-.mysite/
-myapp/
-__init__.py
-models.py
-tests.py
-views.py
-mysite/
-__init__.py
-settings.py
-urls.py
-wsgi.py
-.ebextensions/
-python.config
-manage.py
-mysite.db
-requirements.txt
From my settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mysite.db',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}
Here's python.config:
container_commands: 01_syncdb:
command: "django-admin.py syncdb --noinput"
leader_only: true
option_settings:
- namespace: aws:elasticbeanstalk:container:python
option_name: WSGIPath
value: mysite/wsgi.py
- option_name: DJANGO_SETTINGS_MODULE
value: mysite.settings
- option_name: AWS_SECRET_KEY
value: <This is my secret key>
- option_name: AWS_ACCESS_KEY_ID
value: <This is my access key>
Is there another place I need to define my WSGIPath? Is there a way to do it through the AWS console? Should I just skip EB altogether and use EC2 directly?
From https://forums.aws.amazon.com/thread.jspa?messageID=396656񠵰
The ".ebextensions" directory must be in the root level directory of your application, but from the log output, the directory is instead in the "mysite/.ebextensions" directory. So for example, after following the django tutorial in the docs when you run "git aws.push" your root directory would look like this:
.
├── .ebextensions
│ └── python.config
├── .elasticbeanstalk
│ ├── config
├── .git
├── .gitignore
├── manage.py
├── mysite
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── requirements.txt
Instead of this:
.
└── mysite
├── .ebextensions
├── .elasticbeanstalk
├── .git
├── .gitignore
├── manage.py
├── mysite
└── requirements.txt
这篇关于在AWS上设置Django弹性Beanstalk:找不到WSGIPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!