apache在prefork和worker之间切换:
[root@Wiker ~]# vim/etc/httpd/conf/httpd.conf
<IfModuleprefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
<IfModuleworker.c>
StartServers 4
MaxClients 300
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
MPM方式切换,apache默认是使用的prefork
[root@Wiker ~]#apachectl -l
Compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c
[root@Wiker ~]# lsof -i :80 #prefork默认启动的是8个进程
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 23841 root 4u IPv6 925740 0t0 TCP *:http (LISTEN)
httpd 23844 apache 4u IPv6 925740 0t0 TCP *:http (LISTEN)
httpd 23845 apache 4u IPv6 925740 0t0 TCP *:http (LISTEN)
httpd 23846 apache 4u IPv6 925740 0t0 TCP *:http (LISTEN)
httpd 23847 apache 4u IPv6 925740 0t0 TCP *:http (LISTEN)
httpd 23848 apache 4u IPv6 925740 0t0 TCP *:http (LISTEN)
httpd 23849 apache 4u IPv6 925740 0t0 TCP *:http (LISTEN)
httpd 23850 apache 4u IPv6 925740 0t0 TCP *:http (LISTEN)
httpd 23851 apache 4u IPv6 925740 0t0 TCP *:http (LISTEN)
然后再/etc/sysconfig/httpd里面把下面的参数的#去掉
[root@Wiker ~]# vim/etc/sysconfig/httpd
HTTPD=/usr/sbin/httpd.worker
然后重启httpd服务
[root@Wiker ~]#service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@Wiker ~]#apachectl -l
Compiled in modules:
core.c
worker.c
http_core.c
mod_so.c
[root@Wiker ~]# lsof -i :80 #worker默认启动的是四个进程
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd.wor 23521 root 4u IPv6 923228 0t0 TCP *:http (LISTEN)
httpd.wor 23524apache 4u IPv6 923228 0t0 TCP *:http (LISTEN)
httpd.wor 23525apache 4u IPv6 923228 0t0 TCP *:http (LISTEN)
httpd.wor 23529apache 4u IPv6 923228 0t0 TCP *:http (LISTEN)
转载于:https://blog.51cto.com/wiker/1359588