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

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

## 安装 Gunicorn

安装 gunicorn  执行 `python -m 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) 。
