更新时间:2022-04-05 08:50:31
由于只有一个Django应用程序的实例可以一个Python子间preTER,与mod_wsgi的做事的***方式的上下文中运行会是献给每一个不同的Django的网站需要不同的设置,以不同的mod_wsgi守护进程组。
As only one instance of a Django application can be run within the context of a Python sub interpreter, the best way of doing things with mod_wsgi would be to dedicate each distinct Django site requiring a different settings, to a different mod_wsgi daemon process group.
在这样做,使用一个名称,这显示它应该在WSGI脚本文件中使用,然后在全球范围内的设置文件,设置的名称的mod_wsgi守护进程组 DJANGO_SETTINGS_MODULE
基础上的mod_wsgi守护进程组的名称。
In doing that, use a name for the mod_wsgi daemon process group which reflects the name of the settings file which should be used and then at global scope within the WSGI script file, set DJANGO_SETTINGS_MODULE
based on the name of the mod_wsgi daemon process group.
Apache的配置因此而有这样的:
The Apache configuration would therefore have something like:
WSGIDaemonProcess mysite.settings_1
WSGIDaemonProcess mysite.settings_2
WSGIScriptAlias /suburl process-group=mysite.settings_2 application-group=%{GLOBAL}
WSGIScriptAlias / process-group=mysite.settings_1 application-group=%{GLOBAL}
和WSGI脚本文件:
and the WSGI script file:
import os
try:
import mod_wsgi
except ImportError:
settings_module = 'mysite.settings'
else:
settings_module = mod_wsgi.process_group
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module