reactjs - 通过 gunicorn 运行 django 服务器时模板未加载
问题描述
我正在数字海洋 ubuntu 上部署 django/react 应用程序,为此我创建了一个项目并通过 django 通过创建构建文件夹运行整个应用程序,一切都很好,我创建构建文件夹,使用 python manage.py runserver 0.0 运行 django 服务器。 0.0:8000 并且应用程序加载完美,但是当我使用命令 gunicorn --bind 0.0.0.0:8000 mobilehut.wsgi 通过 gunicorn 运行服务器时,服务器运行成功但模板未加载意味着反应前端未加载,我得到了空白页。
我创建了一个新用户,然后部署,我没有使用 root。我第一次找不到gunicorn有什么问题。有人可以建议我检查什么,是否有 wsgi.py 问题或其他类似的 nginx 文件。
wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mobilehut.settings')
application = get_wsgi_application()
我们需要检查这个吗?/etc/nginx/sites-enabled/default,在这个我尝试用新用户访问-> root var/www/html,它显示权限被拒绝,这是一个问题
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
请提出一些解决方案,我的应用程序在这个 python manage.py runserver 0.0.0.0:8000 上运行良好,但在 gunicorn --bind 0.0.0.0:8000 服务器加载但空白页上没有。
解决方案
推荐阅读
- reactjs - 如何在打字稿中使用数组作为参数?找不到名称“数组”(反应)
- bash - 当文件名中有空格时,无法对目录的内容进行分类
- flutter - Flutter:从底部模式到全屏页面
- php - php循环问题
- python - 在 Python 中从 2 个数据框基准日期创建多个数据框
- angular - 通过 Kubernetes 使 Angular 应用程序可用
- angular - 如何根据语言环境更改数字格式
- mongodb - 在 docker 中安装 tensorflow 和 mongodb 的最佳方法是什么?
- python-3.x - 迭代所有页面和爬虫表的元素,在 Python 中保存为数据框
- excel - 在页脚中设置文本格式