{"title":"部署 Django","version":"3.0","locale":"zh-hans","docname":"howto/deployment/index","url":"/zh-hans/3.0/howto/deployment/","canonical":"https://djangodocs.dev/zh-hans/3.0/howto/deployment/","summary":"Django is full of shortcuts to make Web developers' lives easier, but all those tools are of no use if you can't easily deploy your sites.","html":"<h1>部署 Django<a class=\"heading-anchor\" href=\"#deploying-django\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Django is full of shortcuts to make Web developers' lives easier, but all\nthose tools are of no use if you can't easily deploy your sites. Since Django's\ninception, ease of deployment has been a major goal.</p>\n<p>There are many options for deploying your Django application, based on your\narchitecture or your particular business needs, but that discussion is outside\nthe scope of what Django can give you as guidance.</p>\n<p>Django, being a web framework, needs a web server in order to operate. And\nsince most web servers don't natively speak Python, we need an interface to\nmake that communication happen.</p>\n<p>Django currently supports two interfaces: WSGI and ASGI.</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference external\" href=\"https://wsgi.readthedocs.io/en/latest/\">WSGI</a> is the main Python standard for communicating between Web servers and\napplications, but it only supports synchronous code.</p></li>\n<li><p><a class=\"reference external\" href=\"https://asgi.readthedocs.io/en/latest/\">ASGI</a> is the new, asynchronous-friendly standard that will allow your\nDjango site to use asynchronous Python features, and asynchronous Django\nfeatures as they are developed.</p></li>\n</ul>\n<p>You should also consider how you will handle <a class=\"reference internal\" href=\"/zh-hans/3.0/howto/static-files/deployment/\"><span class=\"doc\">static files</span></a> for your application, and how to handle\n<a class=\"reference internal\" href=\"/zh-hans/3.0/howto/error-reporting/\"><span class=\"doc\">error reporting</span></a>.</p>\n<p>Finally, before you deploy your application to production, you should run\nthrough our <a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/checklist/\"><span class=\"doc\">deployment checklist</span></a> to ensure that your\nconfigurations are suitable.</p>\n<div class=\"toctree-wrapper compound\">\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/wsgi/\">如何使用 WSGI 进行部署</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/wsgi/gunicorn/\">如何使用 Gunicorn 托管 Django</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/wsgi/uwsgi/\">如何用 uWSGI 托管 Django</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/wsgi/modwsgi/\">如何使用 Apache 和 <code class=\"docutils literal notranslate\">mod_wsgi</code> 托管 Django</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/wsgi/apache-auth/\">Apache 利用 Django 的用户数据库进行验证</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/wsgi/#the-application-object\"><code class=\"docutils literal notranslate\">application</code> 对象</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/wsgi/#configuring-the-settings-module\">配置 settings 模块</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/wsgi/#applying-wsgi-middleware\">应用 WSGI 中间件</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/asgi/\">如何使用 ASGI 来部署</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/asgi/daphne/\">How to use Django with Daphne</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/asgi/uvicorn/\">How to use Django with Uvicorn</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/asgi/#the-application-object\"><code class=\"docutils literal notranslate\">application</code> 对象</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/asgi/#configuring-the-settings-module\">配置 settings 模块</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/asgi/#applying-asgi-middleware\">Applying ASGI middleware</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/static-files/deployment/\">部署静态文件</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/static-files/deployment/#serving-static-files-in-production\">在生产环境提供静态文件服务</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/static-files/deployment/#learn-more\">了解更多</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/error-reporting/\">发送错误</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/error-reporting/#email-reports\">通过邮件方式报告</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/error-reporting/#filtering-error-reports\">过滤错误报告</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/checklist/\">部署清单</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/checklist/#run-manage-py-check-deploy\">运行 <code class=\"docutils literal notranslate\">manage.py check --deploy</code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/checklist/#critical-settings\">关键配置</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/checklist/#environment-specific-settings\">特定于环境的配置</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/checklist/#https\">HTTPS</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/checklist/#performance-optimizations\">性能优化</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/3.0/howto/deployment/checklist/#error-reporting\">发送错误</a></li>\n</ul>\n</li>\n</ul>\n</div>","rootId":"deploying-django","toc":[],"breadcrumbs":[{"docname":"howto/index","title":"操作指南","url":"/zh-hans/3.0/howto/"}],"prev":{"docname":"howto/custom-file-storage","title":"编写一个自定义存储系统","url":"/zh-hans/3.0/howto/custom-file-storage/"},"next":{"docname":"howto/deployment/wsgi/index","title":"如何使用 WSGI 进行部署","url":"/zh-hans/3.0/howto/deployment/wsgi/"},"formats":{"html":"/zh-hans/3.0/howto/deployment/","markdown":"/zh-hans/3.0/howto/deployment.md","json":"/zh-hans/3.0/howto/deployment.json"},"source":"https://github.com/django/django/blob/stable/3.0.x/docs/howto/deployment/index.txt","official":"https://docs.djangoproject.com/zh-hans/3.0/howto/deployment/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}