---
title: "如何使用 Gunicorn 托管 Django"
version: 2.2
locale: zh-hans
source: https://docs.djangoproject.com/zh-hans/2.2/howto/deployment/wsgi/gunicorn/
canonical: https://djangodocs.dev/zh-hans/2.2/howto/deployment/wsgi/gunicorn/
---
# 如何使用 Gunicorn 托管 Django

[Gunicorn](https://gunicorn.org/) ('Green Unicorn') 是一个 UNIX 下的纯 Python WSGI 服务器。它没有其它依赖，容易安装和使用。

## 安装 Gunicorn

安装 gunicorn 非常简单，只要执行 `pip install gunicorn` 即可。更多细节请参考 [gunicorn documentation](https://docs.gunicorn.org/en/latest/install.html)。

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

安装 Gunicorn 之后，可以使用 `gunicorn`  命令启动 Gunicorn 服务进程。最简模式下，只需要把包含了 WSGI 应用对象的 application 模块位置告诉 gunicorn，就可以启动了。因此对于典型的 Django 项目，像这样来调用 gunicorn:

```bash
gunicorn myproject.wsgi
```

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

更多技巧请参考 Gunicorn 的 [部署文档](https://docs.gunicorn.org/en/latest/deploy.html) 。
