Apache问题处理服务器访问不了

1. 查看apache的错误日志

我的apache日志文件目录 /var/log/httpd/error.log

[Sun Nov 20 21:17:24 2016] [error] server reached MaxClients setting, consider raising the MaxClients setting 出现问题

2. 百度上面的问题 是因为原来是到了apache的最大连接数了。

检查了一下,这是由于并发链接数太多导致的,后来查了一下apache的文档,发现可以通过修改apache的配置文

/etc/httpd/conf/httpd.conf中的MaxClients参数来调整。

然后在httpd.conf里面配置

<IfModule prefork.c>  

  StartServers     100  

  MinSpareServers  100  

  MaxSpareServers  100  

  ServerLimit     1024  

  MaxClients      1024  

  MaxRequestsPerChild  4000  

</IfModule>  

3. 从这个问题学到了很多关于apache的问题,工作模式,但是我的线上服务器切换老是报错就不敢切换了,

4. 然后,查看了线程中的 httpd 的数量, ps -aux | grep httpd | wc -l 发现,线程数已经达到了 apache 设置的最大值。由此断定是网站访问人数过多造成了访问过慢。 
  为了验证,查看了连接数和当前的连接数,分别是 
    netstat -ant | grep $ip:80 | wc -l 
    netstat -ant | grep $ip:80 | grep EST | wc -l 
    发现果然,连接数特别多,远远超过我们的估计值。

原文地址:https://www.cnblogs.com/shaoshao/p/6088415.html