官方文档 这个 章节的地址如下:
http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html
WSGIDaemonProcess
Description:Configure a distinct daemon process for running applications.
Syntax: WSGIDaemonProcess name [options]
Context tag: server config, virtual host
--// 最值得注意 区分的3个概念 如下:
[option] 里 的 home ==
和 python-home ===
threads ==num
下面分头介绍 如何使用
home == 就是 具体的你的本次被WSGIDeamonProcess 守护的 那个应用程序的绝对地址 (路径)
e.g我的子试验 02 里的 :
WSGIDaemonProcess test_wsgi user=www-data group=www-data threads=5 home=/var/www/html/
这里的home=/var/www/html/ 其实 ,就是 test_wsgi (这个myapp 的物理所在位置)
另外 注意 这个 home== 的地址后面 有 “/”符号
home=directory
Defines an absolute path of a directory which should be used as the
initial current working directory of the daemon processes within the
process group.
If this option is not defined the initial current working directorywill be set to be the home directory of the user that the daemonprocess is configured to run as using theuseroption to theWSGIDaemonProcessdirective. Otherwise the current workingdirectory of Apache when started will be used, which if Apache is beingstarted from system init scripts, would usually be the system rootdirectory.
而 python-home=directory ,其实 就算python 的位置 (多半是你的可以运行起来mod_wsgi 的python的虚拟环境的位置 )
通过你在VPS的虚拟环境里输入 ,python-c'import sys; print(sys.prefix)' ,可以得出
例如在我 的子试验02中,就是
/var/www/firstapp/venv
而 官方文档: http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html?highlight=virtual
里的例子就是 WSGIDaemonProcess myapp python-home=/usr/local/venvs/myapp
另外 注意 这个 home== 的地址后面 没有 (NOT) “/”符号
threads=num
Defines the number of threads to be created to handle requests in each daemon process within the process group. If this option is not defined then the default will be to create 15 threads in each daemon process within the process group. Do not get carried away and set this to a very large number in the belief that it will somehow magically enable you to handle many more concurrent users. Any sort of increased value would only be appropriate where your code is I/O bound. If you code is CPU bound, you are better of using at most 3 to 5 threads per process and using more processes.