0

如果我错了,请纠正我:我可以使用gunicorn 部署一个 django 项目,例如我可以通过这种方式部署我的应用程序 - helloapp:

$ cd env
  $ . bin/activate
  (env) $ cd ..
  (env) $ pip install -r requirements.txt
  (env) root@localhost:/var/www/html/helloapp# gunicorn helloapp.wsgi:application
  [2017-05-18 22:22:38 +0000] [1779] [INFO] Starting gunicorn 19.7.1
  [2017-05-18 22:22:38 +0000] [1779] [INFO] Listening at: http://127.0.0.1:8000 (1779)
  [2017-05-18 22:22:38 +0000] [1779] [INFO] Using worker: sync
  [2017-05-18 22:22:38 +0000] [1783] [INFO] Booting worker with pid: 1783

所以现在我的 django 站点在http://127.0.0.1:8000运行。

但是一旦我关闭/退出我的终端,它将不再可用。那么,即使我关闭了终端,如何让它保持连接到端口 8000 呢?

4

1 回答 1

0

与任何长时间运行的进程一样,您需要在某种管理器下将其作为服务运行。由于您使用的是 Ubuntu,因此您可能想要使用 systemd;完整的说明在gunicorn 部署文档中。请注意,您还需要在 gunicorn 前将 nginx 配置为反向代理。

于 2017-05-19T08:59:54.107 回答