---
title: "如何使用 Gunicorn 托管 Django"
version: 4.2
locale: zh-hans
source: https://docs.djangoproject.com/zh-hans/4.2/howto/deployment/wsgi/gunicorn/
canonical: https://djangodocs.dev/zh-hans/4.2/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 服务器进程。最简单的使用方式是传递包含名为 `application` 的 WSGI 应用程序对象的模块的位置，对于典型的 Django 项目，如下所示：

```shell
gunicorn myproject.wsgi
```

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

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