部署
使用 Apache 和 mod_wsgi 部署 Jam.py
一旦你安装并激活了 mod_wsgi,请编辑你的 Apache 服务器的 httpd.conf 文件并添加以下内容。如果你使用的是 Apache 2.4 之前的版本,请将 Require all granted 替换为 Allow from all,并在其上方添加一行 Order deny,allow。
WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com
<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /path/to/mysite.com/static/
<Directory /path/to/mysite.com/static>
Require all granted
</Directory>
WSGIScriptAlias 行中的第一部分是你想用来服务应用程序的基础 URL 路径(/ 表示根 URL),第二部分是系统中 “WSGI 文件” 的位置——见下文——通常位于你的项目包内(本例中为 mysite )。这告诉 Apache 使用该文件中定义的 WSGI 应用程序来处理给定 URL 下的任何请求。
WSGIPythonPath 行确保你的项目包可以在 Python 路径上被导入;换句话说,确保 import mysite 能够正常工作。
<Directory> 部分只是确保 Apache 能够访问你的 wsgi.py 文件。
接下来的几行确保以 /static/ 开头的所有请求,都会被明确地当作静态文件来处理。
另请参阅
关于部署的更多信息,请参见 如何部署