如何安装 Django¶

安装 Apache 和 mod_wsgi¶

如果您只是想试验 Django,请跳到下一部分;Django 包含一个可用于测试的轻量级 Web 服务器,因此在准备好在生产环境中部署 Django 之前,您不需要设置 Apache。

If you want to use Django on a production site, use Apache with

mod_wsgi. mod_wsgi operates in one of two modes: embedded

mode or daemon mode. In embedded mode, mod_wsgi is similar to

mod_perl -- it embeds Python within Apache and loads Python code into

memory when the server starts. Code stays in memory throughout the

life of an Apache process, which leads to significant performance

gains over other server arrangements. In daemon mode, mod_wsgi spawns

an independent daemon process that handles requests. The daemon

process can run as a different user than the web server, possibly

leading to improved security. The daemon process can be restarted

without restarting the entire Apache web server, possibly making

refreshing your codebase more seamless. Consult the mod_wsgi

documentation to determine which mode is right for your setup. Make

sure you have Apache installed with the mod_wsgi module activated.

Django will work with any version of Apache that supports mod_wsgi.

若已安装 mod_wsgi 模块,请查看 Django 如何利用 mod_wsgi 工作 了解如何配置。

如果由于某种原因你不能使用 mod_wsgi,请不要担心: Django 支持许多其他部署选项。一个是 uWSGI ;它和 nginx 配合使用很好。此外,Django 遵循 WSGI 规范( PEP 3333 ),允许它在各种服务器平台上运行。