Python Django+;Gunincorn-部署并保持与端口的连接?

Python Django+;Gunincorn-部署并保持与端口的连接?,python,django,gunicorn,ubuntu-17.04,Python,Django,Gunicorn,Ubuntu 17.04,如果我错了,请纠正我:我可以使用,例如,我可以通过以下方式部署我的app-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

如果我错了,请纠正我:我可以使用,例如,我可以通过以下方式部署我的app-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站点正在运行


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

与任何长时间运行的进程一样,您需要在某种管理器下将其作为服务运行。既然你在Ubuntu上,你可能想使用systemd;完整的说明请参阅。注意,您还需要将nginx配置为gunicorn前面的反向代理。

如何使用Apache?如果您想使用Apache,应该使用其mod_wsgi插件,而不是gunicorn。再一次,这里有完整的文档和。对于我自己未来的项目,我会使用mod_wsgi插件而不是gunicorn。我有一个传统的django项目,我正在接管它,它使用gunicorn。