使用apache的朋友可能会经常碰到要调整apache环境的连接数与并发数下面我来给大家介绍怎么修改连接数/apache并发数.
Apache的最大连接数,默认为256个。修改apache的最大连接数,方法如下:
步骤一:先修改 /path/apache/conf/httpd.conf文件。
- # vi httpd.conf
- 将“#Include conf/extra/httpd-mpm.conf”前面的 “#” 去掉,保存。
步骤二:再修改 /path/apache/conf/extra/httpd-mpm.conf文件。
- # vi httpd-mpm.conf
找到 这一行,找到文件 /etc/httpd/conf/httpd.conf 并修改下面参数,将默认的256改成1000
- KeepAliveTimeout 15
- ##
- ## Server-Pool Size Regulation (MPM specific)
- ##
- # prefork MPM
- # StartServers: number of server processes to start
- # MinSpareServers: minimum number of server processes which are kept spare
- # MaxSpareServers: maximum number of server processes which are kept spare
- # ServerLimit: maximum value for MaxClients for the lifetime of the server
- # MaxClients: maximum number of server processes allowed to start
- # MaxRequestsPerChild: maximum number of requests a server process serves
- StartServers 8
- MinSpareServers 5
- MaxSpareServers 20
- ServerLimit 1000
- MaxClients 1000
- MaxRequestsPerChild 4000
- ServerLimit 该指令一定要放在第一行。
修改后,一定不要apachectl restart,而是先 apachectl stop 然后再 apachectl start才可以。