如何在 VPS 服务器上 运行 Django 的应用程序服务器

How to run a Django's application server on a VPS server

我有一个应 运行 通过 VPS 基于终端的应用程序,以便网络应用程序可以永久在线。 命令:python manage.py runserver 173.249.8.237:8000 应该通过 VPS 终端执行,因为当我通过笔记本电脑使用 putty 时,每当我通过笔记本电脑关闭 putty 软件时,应用程序将无法访问。 请向我建议一种打开终端的方法,以便 运行 Django 应用程序服务器。 或者,是否有任何方法可以让我在 VPS 上访问我的 Django Web 应用程序?

提前致谢

不要那样做。

runserver 根据 Django Docs

DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making web frameworks, not web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)

您需要在生产环境中将 Django 应用程序配置为 运行。您更改为此选择 docker。

或者简单的运行 gunicorn.

  1. 通过 SSH 或 Putty 访问您的 VPS。
  2. 将您的应用程序代码复制到 VPS
  3. 使用 gunicorn or docker
  4. 将您的应用程序配置为 运行
  5. 在浏览器中访问您的 VPS 地址。
  6. 并开启DEBUG模式,通过设置DEBUG=False