在 Lightsail 的内置 Apache 服务器中托管 Django 应用程序
Host Django application in the Lightsail's built in Apache server
我想要一个带有 Lighsail 的生产就绪的 Django 应用程序,为此我正在学习两个教程来实现这个
从Bitnami的文章可以看出AWS文档遵循其Approach B: Self-Contained Bitnami Installations.
根据:
- AWS的文档,我的blocker出现在5。使用 Apache 托管应用程序,步骤 g.
- Bitnami 的文档,它说
On Linux, you can run the application with mod_wsgi in daemon mode.
Add the following code in
/opt/bitnami/apps/django/django_projects/PROJECT/conf/httpd-app.conf:
阻止程序与我被要求添加的代码有关,尤其是最后一部分
Alias /tutorial/static "/opt/bitnami/apps/django/lib/python3.7/site-packages/Django-2.2.9-py3.7.egg/django/contrib/admin/static"
WSGIScriptAlias /tutorial '/opt/bitnami/apps/django/django_projects/tutorial/tutorial/wsgi.py'
更具体地说,/home/bitnami/apps/django/
。在/home/bitnami/
中只能看到以下文件夹
. bitnami_application_password
. bitnami_credentials
.文档
.堆叠
从他们中最有可能与 /opt/bitnami/apps/
相似的是 /home/bitnami/stack/
。事情是,在那个特定文件夹内,没有 django 文件夹 - 至少据我所知(已经检查了它的一些文件夹,比如 python 一个)。
在这个特定阶段,我的解决方法是转向不同的方法,Approach A: Bitnami Installations Using System Packages (which I've done and managed to make it work as wrote in this blog post),但我想使用方法 B 让它工作,因此这个问题。
这里的问题在于提到项目和 Django 的路径。
在我的例子中,项目在 /home/bitnami/projects/
下,我在其中创建了一个名为 tutorial 的 Django 项目。
此外,如果我 运行 命令
python -c "
import sys
sys.path = sys.path[1:]
import django
print(django.__path__)"
它会打印出 Django 的安装位置
['/opt/bitnami/python/lib/python3.8/site-packages/django']
所以,httpd-app.conf 应该放在最后
Alias /tutorial/static "/opt/bitnami/python/lib/python3.8/site-packages/django/contrib/admin/static"
WSGIScriptAlias /tutorial '/home/bitnami/projects/tutorial/tutorial/wsgi.py'
我想要一个带有 Lighsail 的生产就绪的 Django 应用程序,为此我正在学习两个教程来实现这个
从Bitnami的文章可以看出AWS文档遵循其Approach B: Self-Contained Bitnami Installations.
根据:
- AWS的文档,我的blocker出现在5。使用 Apache 托管应用程序,步骤 g.
- Bitnami 的文档,它说
On Linux, you can run the application with mod_wsgi in daemon mode. Add the following code in /opt/bitnami/apps/django/django_projects/PROJECT/conf/httpd-app.conf:
阻止程序与我被要求添加的代码有关,尤其是最后一部分
Alias /tutorial/static "/opt/bitnami/apps/django/lib/python3.7/site-packages/Django-2.2.9-py3.7.egg/django/contrib/admin/static"
WSGIScriptAlias /tutorial '/opt/bitnami/apps/django/django_projects/tutorial/tutorial/wsgi.py'
更具体地说,/home/bitnami/apps/django/
。在/home/bitnami/
中只能看到以下文件夹
. bitnami_application_password
. bitnami_credentials
.文档
.堆叠
从他们中最有可能与 /opt/bitnami/apps/
相似的是 /home/bitnami/stack/
。事情是,在那个特定文件夹内,没有 django 文件夹 - 至少据我所知(已经检查了它的一些文件夹,比如 python 一个)。
在这个特定阶段,我的解决方法是转向不同的方法,Approach A: Bitnami Installations Using System Packages (which I've done and managed to make it work as wrote in this blog post),但我想使用方法 B 让它工作,因此这个问题。
这里的问题在于提到项目和 Django 的路径。
在我的例子中,项目在 /home/bitnami/projects/
下,我在其中创建了一个名为 tutorial 的 Django 项目。
此外,如果我 运行 命令
python -c "
import sys
sys.path = sys.path[1:]
import django
print(django.__path__)"
它会打印出 Django 的安装位置
['/opt/bitnami/python/lib/python3.8/site-packages/django']
所以,httpd-app.conf 应该放在最后
Alias /tutorial/static "/opt/bitnami/python/lib/python3.8/site-packages/django/contrib/admin/static"
WSGIScriptAlias /tutorial '/home/bitnami/projects/tutorial/tutorial/wsgi.py'