“Django/docs/3.0.x/howto/deployment/wsgi/gunicorn”的版本间差异
来自菜鸟教程
Django/docs/3.0.x/howto/deployment/wsgi/gunicorn
(autoload) |
小 (Page commit) |
||
第1行: | 第1行: | ||
+ | {{DISPLAYTITLE:如何在 Gunicorn 中使用 Django — Django 文档}} | ||
<div id="how-to-use-django-with-gunicorn" class="section"> | <div id="how-to-use-django-with-gunicorn" class="section"> | ||
− | = | + | = 如何在 Gunicorn 中使用 Django = |
− | [https://gunicorn.org/ Gunicorn] ('Green Unicorn') | + | [https://gunicorn.org/ Gunicorn] ('Green Unicorn') 是一个用于 UNIX 的纯 Python WSGI 服务器。 它没有依赖项,可以使用 <code>pip</code> 安装。 |
− | |||
<div id="installing-gunicorn" class="section"> | <div id="installing-gunicorn" class="section"> | ||
第10行: | 第10行: | ||
== 安装 Gunicorn == | == 安装 Gunicorn == | ||
− | + | 通过运行 <code>python -m pip install gunicorn</code> 安装 gunicorn。 有关更多详细信息,请参阅 [https://docs.gunicorn.org/en/latest/install.html gunicorn 文档] 。 | |
− | |||
第17行: | 第16行: | ||
<div id="running-django-in-gunicorn-as-a-generic-wsgi-application" class="section"> | <div id="running-django-in-gunicorn-as-a-generic-wsgi-application" class="section"> | ||
− | == | + | == 在 Gunicorn 中将 Django 作为通用 WSGI 应用程序运行 == |
− | + | 安装 Gunicorn 后,可以使用 <code>gunicorn</code> 命令启动 Gunicorn 服务器进程。 对 gunicorn 的最简单调用是传递包含名为 <code>application</code> 的 WSGI 应用程序对象的模块的位置,对于典型的 Django 项目,它如下所示: | |
− | |||
− | |||
− | <code>application</code> | ||
<div class="highlight-bash notranslate"> | <div class="highlight-bash notranslate"> | ||
第28行: | 第24行: | ||
<div class="highlight"> | <div class="highlight"> | ||
− | < | + | <syntaxhighlight lang="bash">gunicorn myproject.wsgi</syntaxhighlight> |
</div> | </div> | ||
</div> | </div> | ||
− | + | 这将启动一个进程运行一个线程监听 <code>127.0.0.1:8000</code>。 它要求你的项目在 Python 路径上; 确保这一点的最简单方法是从与 <code>manage.py</code> 文件相同的目录中运行此命令。 | |
− | + | 有关其他提示,请参阅 Gunicorn 的 [https://docs.gunicorn.org/en/latest/deploy.html 部署文档] 。 | |
第41行: | 第37行: | ||
</div> | </div> | ||
+ | <div class="clearer"> | ||
− | [[Category:Django 3.0.x | + | |
+ | |||
+ | </div> | ||
+ | |||
+ | [[Category:Django 3.0.x 文档]] |
2021年10月31日 (日) 04:08的最新版本
如何在 Gunicorn 中使用 Django
Gunicorn ('Green Unicorn') 是一个用于 UNIX 的纯 Python WSGI 服务器。 它没有依赖项,可以使用 pip
安装。
在 Gunicorn 中将 Django 作为通用 WSGI 应用程序运行
安装 Gunicorn 后,可以使用 gunicorn
命令启动 Gunicorn 服务器进程。 对 gunicorn 的最简单调用是传递包含名为 application
的 WSGI 应用程序对象的模块的位置,对于典型的 Django 项目,它如下所示:
这将启动一个进程运行一个线程监听 127.0.0.1:8000
。 它要求你的项目在 Python 路径上; 确保这一点的最简单方法是从与 manage.py
文件相同的目录中运行此命令。
有关其他提示,请参阅 Gunicorn 的 部署文档 。