“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 =
+
= 如何在 Gunicorn 中使用 Django =
  
[https://gunicorn.org/ Gunicorn] ('Green Unicorn') is a pure-Python WSGI server for UNIX. It has no
+
[https://gunicorn.org/ Gunicorn] ('Green Unicorn') 是一个用于 UNIX 的纯 Python WSGI 服务器。 它没有依赖项,可以使用 <code>pip</code> 安装。
dependencies and can be installed using <code>pip</code>.
 
  
 
<div id="installing-gunicorn" class="section">
 
<div id="installing-gunicorn" class="section">
第10行: 第10行:
 
== 安装 Gunicorn ==
 
== 安装 Gunicorn ==
  
Install gunicorn by running <code>python -m pip install gunicorn</code>. For more
+
通过运行 <code>python -m pip install gunicorn</code> 安装 gunicorn。 有关更多详细信息,请参阅 [https://docs.gunicorn.org/en/latest/install.html gunicorn 文档]
details, see the [https://docs.gunicorn.org/en/latest/install.html gunicorn documentation].
 
  
  
第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">
  
== Django 当作普通 WSGI 应用在 Gunicorn 中运行 ==
+
== 在 Gunicorn 中将 Django 作为通用 WSGI 应用程序运行 ==
  
When Gunicorn is installed, a <code>gunicorn</code> command is available which starts
+
安装 Gunicorn 后,可以使用 <code>gunicorn</code> 命令启动 Gunicorn 服务器进程。 对 gunicorn 的最简单调用是传递包含名为 <code>application</code> 的 WSGI 应用程序对象的模块的位置,对于典型的 Django 项目,它如下所示:
the Gunicorn server process. The simplest invocation of gunicorn is to pass the
 
location of a module containing a WSGI application object named
 
<code>application</code>, which for a typical Django project would look like:
 
  
 
<div class="highlight-bash notranslate">
 
<div class="highlight-bash notranslate">
第28行: 第24行:
 
<div class="highlight">
 
<div class="highlight">
  
<pre>gunicorn myproject.wsgi</pre>
+
<syntaxhighlight lang="bash">gunicorn myproject.wsgi</syntaxhighlight>
  
 
</div>
 
</div>
  
 
</div>
 
</div>
这样会创建一个进程,包含了一个监听在 <code>127.0.0.1:8000</code> 的线程。前提是你的项目在 Python path 中,要满足这个条件,最简单的方法是在 <code>manage.py</code> 文件所在的目录中运行这条命令。
+
这将启动一个进程运行一个线程监听 <code>127.0.0.1:8000</code>。 它要求你的项目在 Python 路径上; 确保这一点的最简单方法是从与 <code>manage.py</code> 文件相同的目录中运行此命令。
  
更多技巧请参考 Gunicorn 的 [https://docs.gunicorn.org/en/latest/deploy.html 部署文档] 。
+
有关其他提示,请参阅 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

通过运行 python -m pip install gunicorn 安装 gunicorn。 有关更多详细信息,请参阅 gunicorn 文档


在 Gunicorn 中将 Django 作为通用 WSGI 应用程序运行

安装 Gunicorn 后,可以使用 gunicorn 命令启动 Gunicorn 服务器进程。 对 gunicorn 的最简单调用是传递包含名为 application 的 WSGI 应用程序对象的模块的位置,对于典型的 Django 项目,它如下所示:

gunicorn myproject.wsgi

这将启动一个进程运行一个线程监听 127.0.0.1:8000。 它要求你的项目在 Python 路径上; 确保这一点的最简单方法是从与 manage.py 文件相同的目录中运行此命令。

有关其他提示,请参阅 Gunicorn 的 部署文档