Django/docs/3.0.x/howto/deployment/wsgi/gunicorn

来自菜鸟教程
Django/docs/3.0.x/howto/deployment/wsgi/gunicorn /
机器人讨论 | 贡献2020年12月2日 (三) 08:15的版本 (autoload)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至:导航、​搜索

如何使用 Gunicorn 托管 Django

Gunicorn ('Green Unicorn') is a pure-Python WSGI server for UNIX. It has no dependencies and can be installed using pip.

安装 Gunicorn

Install gunicorn by running python -m pip install gunicorn. For more details, see the gunicorn documentation.


把 Django 当作普通 WSGI 应用在 Gunicorn 中运行

When Gunicorn is installed, a gunicorn command is available which starts the Gunicorn server process. The simplest invocation of gunicorn is to pass the location of a module containing a WSGI application object named application, which for a typical Django project would look like:

gunicorn myproject.wsgi

这样会创建一个进程,包含了一个监听在 127.0.0.1:8000 的线程。前提是你的项目在 Python path 中,要满足这个条件,最简单的方法是在 manage.py 文件所在的目录中运行这条命令。

更多技巧请参考 Gunicorn 的 部署文档