使用modwsgi
在apache上运行python / django我一直在寻找通过我的apache error_log而且我注意到了一些奇怪的事情
我只有2个带wsgi守护进程的虚拟主机 但是当我启动httpd服务时,我得到了很多python初始化(我已经算了17次)
这是另一个就像这样
WSGIDaemonProcess myproject python-path=/home/xyz/public_html/myproject:/usr/local/lib/python3.4/site-packages/
WSGIProcessGroup myproject
WSGIScriptAlias / /home/xyz/public_html/myproject/myproject/wsgi.py
<Directory /home/xyz/public_html/myproject/myproject>
<Files wsgi.py>
Order deny,allow
Require all granted
WSGIProcessGroup myproject
</Files>
</Directory>
Alias /static/ /home/xyz/public_html/myproject/static/
<Directory /home/xyz/public_html/myproject/static>
Require all granted
</Directory>
这是我启动httpd时得到的内容
[Tue Nov 22 06:23:46.979171 2016] [unique_id:info] [pid 14914] AH01566: using ip addr 136.243.122.67
[Tue Nov 22 06:23:47.000460 2016] [ssl:info] [pid 14914] AH01887: Init: Initializing (virtual) servers for SSL
[Tue Nov 22 06:23:47.000491 2016] [ssl:info] [pid 14914] AH01914: Configuring server static.67.122.243.136.clients.your-server.de:443 for SSL protocol
[Tue Nov 22 06:23:47.002249 2016] [ssl:info] [pid 14914] AH02568: Certificate and private key static.67.122.243.136.clients.your-server.de:443:0 configured from /var/cpanel/ssl/cpanel/mycpanel.pem and /var/cpanel/ssl/cpanel/mycpanel.pem
[Tue Nov 22 06:23:47.002850 2016] [ssl:info] [pid 14914] AH01876: mod_ssl/2.4.18 compiled against Server: Apache/2.4.18, Library: OpenSSL/1.0.1e
[Tue Nov 22 06:23:47.002916 2016] [suexec:notice] [pid 14914] AH01232: suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
[Tue Nov 22 06:23:47.003027 2016] [:notice] [pid 14914] ModSecurity for Apache/2.9.0 (http://www.modsecurity.org/) configured.
[Tue Nov 22 06:23:47.003036 2016] [:notice] [pid 14914] ModSecurity: APR compiled version="1.5.2"; loaded version="1.5.2"
[Tue Nov 22 06:23:47.003042 2016] [:notice] [pid 14914] ModSecurity: PCRE compiled version="8.38 "; loaded version="8.38 2015-11-23"
[Tue Nov 22 06:23:47.003048 2016] [:notice] [pid 14914] ModSecurity: LUA compiled version="Lua 5.1"
[Tue Nov 22 06:23:47.003052 2016] [:notice] [pid 14914] ModSecurity: LIBXML compiled version="2.9.2"
[Tue Nov 22 06:23:47.003056 2016] [:notice] [pid 14914] ModSecurity: Status engine is currently disabled, enable it by set SecStatusEngine to On.
[Tue Nov 22 06:23:47.065136 2016] [unique_id:info] [pid 14915] AH01566: using ip addr 136.243.122.67
[Tue Nov 22 06:23:48.001185 2016] [socache_shmcb:info] [pid 14915] AH00830: Shared memory socache initialised
[Tue Nov 22 06:23:48.001313 2016] [socache_shmcb:info] [pid 14915] AH00830: Shared memory socache initialised
[Tue Nov 22 06:23:48.001319 2016] [ssl:info] [pid 14915] AH01887: Init: Initializing (virtual) servers for SSL
[Tue Nov 22 06:23:48.001324 2016] [ssl:info] [pid 14915] AH01914: Configuring server static.67.122.243.136.clients.your-server.de:443 for SSL protocol
[Tue Nov 22 06:23:48.002274 2016] [ssl:info] [pid 14915] AH02568: Certificate and private key static.67.122.243.136.clients.your-server.de:443:0 configured from /var/cpanel/ssl/cpanel/mycpanel.pem and /var/cpanel/ssl/cpanel/mycpanel.pem
[Tue Nov 22 06:23:48.002581 2016] [ssl:info] [pid 14915] AH01876: mod_ssl/2.4.18 compiled against Server: Apache/2.4.18, Library: OpenSSL/1.0.1e
[Tue Nov 22 06:23:48.005064 2016] [wsgi:info] [pid 14917] mod_wsgi (pid=14917): Starting process 'myproject' with uid=99, gid=99 and threads=15.
[Tue Nov 22 06:23:48.005389 2016] [wsgi:info] [pid 14918] mod_wsgi (pid=14918): Starting process 'adminmyproject' with uid=99, gid=99 and threads=15.
[Tue Nov 22 06:23:48.006008 2016] [wsgi:info] [pid 14917] mod_wsgi (pid=14917): Initializing Python.
[Tue Nov 22 06:23:48.006745 2016] [wsgi:info] [pid 14919] mod_wsgi (pid=14919): Initializing Python.
[Tue Nov 22 06:23:48.006939 2016] [mpm_prefork:notice] [pid 14915] AH00163: Apache/2.4.18 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 mod_wsgi/4.5.2 Python/3.4.4 configured -- resuming normal operations
[Tue Nov 22 06:23:48.006950 2016] [mpm_prefork:info] [pid 14915] AH00164: Server built: Jun 13 2016 22:00:03
[Tue Nov 22 06:23:48.006972 2016] [core:notice] [pid 14915] AH00094: Command line: '/usr/local/apache/bin/httpd'
[Tue Nov 22 06:23:48.007462 2016] [wsgi:info] [pid 14920] mod_wsgi (pid=14920): Initializing Python.
[Tue Nov 22 06:23:48.014889 2016] [wsgi:info] [pid 14918] mod_wsgi (pid=14918): Initializing Python.
[Tue Nov 22 06:23:48.017097 2016] [wsgi:info] [pid 14922] mod_wsgi (pid=14922): Initializing Python.
[Tue Nov 22 06:23:48.017441 2016] [wsgi:info] [pid 14921] mod_wsgi (pid=14921): Initializing Python.
[Tue Nov 22 06:23:48.034254 2016] [wsgi:info] [pid 14920] mod_wsgi (pid=14920): Attach interpreter ''.
[Tue Nov 22 06:23:48.037473 2016] [wsgi:info] [pid 14923] mod_wsgi (pid=14923): Initializing Python.
[Tue Nov 22 06:23:48.046362 2016] [wsgi:info] [pid 14922] mod_wsgi (pid=14922): Attach interpreter ''.
[Tue Nov 22 06:23:48.056491 2016] [wsgi:info] [pid 14921] mod_wsgi (pid=14921): Attach interpreter ''.
[Tue Nov 22 06:23:48.068671 2016] [wsgi:info] [pid 14923] mod_wsgi (pid=14923): Attach interpreter ''.
[Tue Nov 22 06:23:48.075155 2016] [wsgi:info] [pid 14918] mod_wsgi (pid=14918): Attach interpreter ''.
[Tue Nov 22 06:23:48.076183 2016] [wsgi:info] [pid 14918] mod_wsgi (pid=14918): Adding '/home/tttsdgf4/public_html/paypal_admin' to path.
[Tue Nov 22 06:23:48.076443 2016] [wsgi:info] [pid 14918] mod_wsgi (pid=14918): Adding '/usr/local/lib/python3.4/site-packages/' to path.
[Tue Nov 22 06:23:48.078562 2016] [wsgi:info] [pid 14919] mod_wsgi (pid=14919): Attach interpreter ''.
[Tue Nov 22 06:23:48.082261 2016] [wsgi:info] [pid 14917] mod_wsgi (pid=14917): Attach interpreter ''.
[Tue Nov 22 06:23:48.083561 2016] [wsgi:info] [pid 14917] mod_wsgi (pid=14917): Adding '/home/xyz/public_html/myproject' to path.
[Tue Nov 22 06:23:48.083908 2016] [wsgi:info] [pid 14917] mod_wsgi (pid=14917): Adding '/usr/local/lib/python3.4/site-packages/' to path.
(XID uurvwj) Database Connect Error: Access denied for user 'leechprotect'@'localhost' (using password: YES)
[Tue Nov 22 06:23:52.732171 2016] [wsgi:info] [pid 14917] mod_wsgi (pid=14917): Create interpreter 'myproject.com|'.
[Tue Nov 22 06:23:52.762576 2016] [wsgi:info] [pid 14917] mod_wsgi (pid=14917): Adding '/home/xyz/public_html/myproject' to path.
[Tue Nov 22 06:23:52.763093 2016] [wsgi:info] [pid 14917] mod_wsgi (pid=14917): Adding '/usr/local/lib/python3.4/site-packages/' to path.
[Tue Nov 22 06:23:52.764574 2016] [wsgi:info] [pid 14917] [remote 178.253.28.32:0] mod_wsgi (pid=14917, process='myproject', application='myproject.com|'): Loading WSGI script '/home/xyz/public_html/myproject/myproject/wsgi.py'.
[Tue Nov 22 06:23:53.014092 2016] [wsgi:info] [pid 14959] mod_wsgi (pid=14959): Initializing Python.
[Tue Nov 22 06:23:53.052726 2016] [wsgi:info] [pid 14959] mod_wsgi (pid=14959): Attach interpreter ''.
[Tue Nov 22 06:23:55.016852 2016] [wsgi:info] [pid 14961] mod_wsgi (pid=14961): Initializing Python.
[Tue Nov 22 06:23:55.035254 2016] [wsgi:info] [pid 14961] mod_wsgi (pid=14961): Attach interpreter ''.
[Tue Nov 22 06:23:56.020259 2016] [wsgi:info] [pid 14962] mod_wsgi (pid=14962): Initializing Python.
[Tue Nov 22 06:23:56.020497 2016] [wsgi:info] [pid 14963] mod_wsgi (pid=14963): Initializing Python.
[Tue Nov 22 06:23:56.056777 2016] [wsgi:info] [pid 14963] mod_wsgi (pid=14963): Attach interpreter ''.
[Tue Nov 22 06:23:56.057672 2016] [wsgi:info] [pid 14962] mod_wsgi (pid=14962): Attach interpreter ''.
[Tue Nov 22 06:23:57.023399 2016] [wsgi:info] [pid 14966] mod_wsgi (pid=14966): Initializing Python.
[Tue Nov 22 06:23:57.024092 2016] [wsgi:info] [pid 14967] mod_wsgi (pid=14967): Initializing Python.
[Tue Nov 22 06:23:57.024797 2016] [wsgi:info] [pid 14968] mod_wsgi (pid=14968): Initializing Python.
[Tue Nov 22 06:23:57.025605 2016] [wsgi:info] [pid 14969] mod_wsgi (pid=14969): Initializing Python.
[Tue Nov 22 06:23:57.057302 2016] [wsgi:info] [pid 14966] mod_wsgi (pid=14966): Attach interpreter ''.
[Tue Nov 22 06:23:57.059648 2016] [wsgi:info] [pid 14969] mod_wsgi (pid=14969): Attach interpreter ''.
[Tue Nov 22 06:23:57.061447 2016] [wsgi:info] [pid 14967] mod_wsgi (pid=14967): Attach interpreter ''.
[Tue Nov 22 06:23:57.079172 2016] [wsgi:info] [pid 14968] mod_wsgi (pid=14968): Attach interpreter ''.
这是正常还是有问题?
答案 0 :(得分:1)
这似乎要启动很多流程。您可以尝试向WSGIDaemonProcess
添加一些额外的参数,以显式设置它应该生成的进程数和线程数。在你的情况下,尝试这样的事情(注意最右边的指令):
WSGIDaemonProcess myproject python-path=/home/xyz/public_html/myproject:/usr/local/lib/python3.4/site-packages/ processes=2 threads=5
此处有关这些指令的更多信息:http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html
答案 1 :(得分:1)
关闭Apache子进程中Python解释器的初始化。读:
这样Python只会在mod_wsgi守护进程中初始化。