django Gunicorn 和 nginx 代理给出 504 错误

发布于 2025-01-07 17:19:58 字数 741 浏览 3 评论 0原文

我浏览了所有相关问题但找不到答案,我也浏览了文档并尝试了所有我能做的,这是我的第一次,因此遇到了困难。 我有一个简单的 django polls 应用程序,具有正确的设置和静态文件,在本地工作。

正如标题中提到的,我尝试在新购买的 VPS 上使用 django,使用 nginx 和 Gunicorn,我也使用 virtualenv。

这是我在服务器上的文件夹结构: projhome 内的logs pid projhome scripts

我有以下目录: bin djangopolls include lib local

正如已经提到的,与我拥有的 projhome 文件夹并行脚本文件夹,包含以下内容:

source /home/django/projhq/bin/activate
kill `cat /home/username/pid/gunicorn.pid`
gunicorn_django -c /home/username/projhome/djangopolls/gunicorn_cfg.py

现在要启动服务器,我需要转到脚本文件夹并运行启动脚本,我这样做没有任何错误,但是当我检查 IP 时,我得到 504错误。

我哪里错了???

I went through all the related questions and could not find the answer, i went through the docs as well and tried all that i could, its my first time, hence having a hard time.
I have a simple django polls app with proper settings and static files, working locally.

As mentioned in the title i am trying to use django on a newly bought VPS, with nginx and gunicorn, i am using virtualenv as well.

Here is my folder structure on the server:
logs pid projhome scripts

inside the projhome i have the following directories:
bin djangopolls include lib local

as already mentioned parallel to the projhome folder i have scripts folder, with the following content:

source /home/django/projhq/bin/activate
kill `cat /home/username/pid/gunicorn.pid`
gunicorn_django -c /home/username/projhome/djangopolls/gunicorn_cfg.py

Now to start the server i need to go to the scripts folder and run the start script, i do that without any error, but when i check the IP i get 504 error.

Where am i wrong???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

女皇必胜 2025-01-14 17:19:58

您可能首先需要 cd 进入 settings.py 文件所在的目录,然后运行 ​​Gunicorn,这样您就可以更新 script.sh 以首先 cd 进入 django 项目目录。

you might first want to cd into the directory where settings.py file is placed and then run gunicorn, so you can update your script.sh to first cd into the django project directory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文