apache2每天都会崩溃1到3次

时间:2016-05-12 14:31:27

标签: linux debian apache2.4

我正在使用apache 2.4和php 7运行debian服务器。* 每天1 - 3次我的网站关闭,我必须重新启动apache才能重新启动它。

我对Linux很新,所以我真的不知道如何调试apache:/

任何建议都非常有用!

服务器统计信息:

ram:32 Gb ram

hd:2x 256Gb ssh 600 / 600Mb

2个拥有6个核心的CPU我不记得cpus的统计数据

崩溃前的

apache状态:

 ● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
   Active: active (running) since Thu 2016-05-12 16:31:45 CEST; 2s ago
  Process: 1540 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 27533 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
  Process: 1566 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/apache2.service
           ├─1581 /usr/sbin/apache2 -k start
           ├─1584 /usr/sbin/apache2 -k start
           ├─1585 /usr/sbin/apache2 -k start
           ├─1586 /usr/sbin/apache2 -k start
           ├─1587 /usr/sbin/apache2 -k start
           └─1588 /usr/sbin/apache2 -k start

May 12 16:31:45 something.com apache2[1566]: Starting web server: apac...
May 12 16:31:45 something.com systemd[1]: Started LSB: Apache2 web se....
Hint: Some lines were ellipsized, use -l to show in full.
崩溃后的

apache状态:

   apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
   Active: active (running) since Wed 2016-05-11 13:06:04 CEST; 1 day 3h ago
  Process: 16209 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 27533 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
  Process: 16234 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/apache2.service
           ├─16249 /usr/sbin/apache2 -k start
           ├─16268 /usr/sbin/apache2 -k start
           ├─16290 /usr/sbin/apache2 -k start
           ├─16299 /usr/sbin/apache2 -k start
           ├─16382 /usr/sbin/apache2 -k start
           ├─16385 /usr/sbin/apache2 -k start
           ├─16388 /usr/sbin/apache2 -k start
           ├─16437 /usr/sbin/apache2 -k start
           ├─16513 /usr/sbin/apache2 -k start
           ├─16660 /usr/sbin/apache2 -k start
           ├─16930 /usr/sbin/apache2 -k start
           ├─16934 /usr/sbin/apache2 -k start
           ├─16946 /usr/sbin/apache2 -k start
           ├─16976 /usr/sbin/apache2 -k start
           ├─16983 /usr/sbin/apache2 -k start
           ├─16989 /usr/sbin/apache2 -k start
           ├─16991 /usr/sbin/apache2 -k start
           ├─17171 /usr/sbin/apache2 -k start
           ├─17190 /usr/sbin/apache2 -k start
           ├─17270 /usr/sbin/apache2 -k start
           ├─17319 /usr/sbin/apache2 -k start
           ├─17320 /usr/sbin/apache2 -k start
           ├─17377 /usr/sbin/apache2 -k start
           ├─17383 /usr/sbin/apache2 -k start
           ├─17387 /usr/sbin/apache2 -k start
           ├─17407 /usr/sbin/apache2 -k start
           ├─17412 /usr/sbin/apache2 -k start
           ├─17722 /usr/sbin/apache2 -k start
           ├─17750 /usr/sbin/apache2 -k start
           ├─17753 /usr/sbin/apache2 -k start
           ├─17756 /usr/sbin/apache2 -k start
           ├─17757 /usr/sbin/apache2 -k start
           ├─17836 /usr/sbin/apache2 -k start
           ├─17858 /usr/sbin/apache2 -k start
           ├─17873 /usr/sbin/apache2 -k start
           ├─17883 /usr/sbin/apache2 -k start
           ├─17885 /usr/sbin/apache2 -k start
           ├─17937 /usr/sbin/apache2 -k start
           ├─17938 /usr/sbin/apache2 -k start
           ├─17945 /usr/sbin/apache2 -k start
           ├─17949 /usr/sbin/apache2 -k start
           ├─17953 /usr/sbin/apache2 -k start
           ├─18006 /usr/sbin/apache2 -k start
           ├─18015 /usr/sbin/apache2 -k start
           ├─18080 /usr/sbin/apache2 -k start
           ├─18092 /usr/sbin/apache2 -k start
           ├─18097 /usr/sbin/apache2 -k start
           ├─18154 /usr/sbin/apache2 -k start
           ├─18223 /usr/sbin/apache2 -k start
           ├─18224 /usr/sbin/apache2 -k start
           ├─18226 /usr/sbin/apache2 -k start
           ├─18239 /usr/sbin/apache2 -k start
           ├─18342 /usr/sbin/apache2 -k start
           ├─18347 /usr/sbin/apache2 -k start
           ├─18348 /usr/sbin/apache2 -k start
           ├─18353 /usr/sbin/apache2 -k start
           ├─18364 /usr/sbin/apache2 -k start
           ├─18399 /usr/sbin/apache2 -k start
           ├─18403 /usr/sbin/apache2 -k start
           ├─18404 /usr/sbin/apache2 -k start
           ├─18419 /usr/sbin/apache2 -k start
           ├─18451 /usr/sbin/apache2 -k start
           ├─18526 /usr/sbin/apache2 -k start
           ├─18531 /usr/sbin/apache2 -k start
           ├─18583 /usr/sbin/apache2 -k start
           ├─18603 /usr/sbin/apache2 -k start
           ├─18628 /usr/sbin/apache2 -k start
           ├─18647 /usr/sbin/apache2 -k start
           ├─18697 /usr/sbin/apache2 -k start
           ├─18699 /usr/sbin/apache2 -k start
           ├─18706 /usr/sbin/apache2 -k start
           ├─18714 /usr/sbin/apache2 -k start
           ├─18731 /usr/sbin/apache2 -k start
           ├─18732 /usr/sbin/apache2 -k start
           ├─18736 /usr/sbin/apache2 -k start
           ├─18737 /usr/sbin/apache2 -k start
           ├─18754 /usr/sbin/apache2 -k start
           ├─18791 /usr/sbin/apache2 -k start
           ├─18804 /usr/sbin/apache2 -k start
           ├─18811 /usr/sbin/apache2 -k start
           ├─18812 /usr/sbin/apache2 -k start
           ├─18818 /usr/sbin/apache2 -k start
           ├─18819 /usr/sbin/apache2 -k start
           ├─18822 /usr/sbin/apache2 -k start
           ├─18832 /usr/sbin/apache2 -k start
           ├─18844 /usr/sbin/apache2 -k start
           ├─18845 /usr/sbin/apache2 -k start
           ├─18846 /usr/sbin/apache2 -k start
           ├─18852 /usr/sbin/apache2 -k start
           ├─18856 /usr/sbin/apache2 -k start
           ├─18919 /usr/sbin/apache2 -k start
           ├─18927 /usr/sbin/apache2 -k start
           ├─18934 /usr/sbin/apache2 -k start
           ├─18940 /usr/sbin/apache2 -k start
           ├─18956 /usr/sbin/apache2 -k start
           ├─18962 /usr/sbin/apache2 -k start
           ├─18967 /usr/sbin/apache2 -k start
           ├─18968 /usr/sbin/apache2 -k start
           ├─18973 /usr/sbin/apache2 -k start
           ├─18977 /usr/sbin/apache2 -k start
           ├─18983 /usr/sbin/apache2 -k start
           ├─19022 /usr/sbin/apache2 -k start
           ├─19076 /usr/sbin/apache2 -k start
           ├─19083 /usr/sbin/apache2 -k start
           ├─19095 /usr/sbin/apache2 -k start
           ├─19096 /usr/sbin/apache2 -k start
           ├─19107 /usr/sbin/apache2 -k start
           ├─19114 /usr/sbin/apache2 -k start
           ├─19116 /usr/sbin/apache2 -k start
           ├─19125 /usr/sbin/apache2 -k start
           ├─19126 /usr/sbin/apache2 -k start
           ├─19128 /usr/sbin/apache2 -k start
           ├─19130 /usr/sbin/apache2 -k start
           ├─19131 /usr/sbin/apache2 -k start
           ├─19139 /usr/sbin/apache2 -k start
           ├─19141 /usr/sbin/apache2 -k start
           ├─19143 /usr/sbin/apache2 -k start
           ├─19154 /usr/sbin/apache2 -k start
           ├─19158 /usr/sbin/apache2 -k start
           ├─19161 /usr/sbin/apache2 -k start
           ├─19166 /usr/sbin/apache2 -k start
           ├─19167 /usr/sbin/apache2 -k start
           ├─19168 /usr/sbin/apache2 -k start
           ├─19169 /usr/sbin/apache2 -k start
           ├─19171 /usr/sbin/apache2 -k start
           ├─19203 /usr/sbin/apache2 -k start
           ├─19204 /usr/sbin/apache2 -k start
           ├─19220 /usr/sbin/apache2 -k start
           ├─19222 /usr/sbin/apache2 -k start
           ├─19223 /usr/sbin/apache2 -k start
           ├─19225 /usr/sbin/apache2 -k start
           ├─19226 /usr/sbin/apache2 -k start
           ├─19227 /usr/sbin/apache2 -k start
           ├─19228 /usr/sbin/apache2 -k start
           ├─19232 /usr/sbin/apache2 -k start
           ├─19235 /usr/sbin/apache2 -k start
           ├─19236 /usr/sbin/apache2 -k start
           ├─19237 /usr/sbin/apache2 -k start
           ├─19238 /usr/sbin/apache2 -k start
           ├─19241 /usr/sbin/apache2 -k start
           ├─19243 /usr/sbin/apache2 -k start
           ├─19249 /usr/sbin/apache2 -k start
           ├─19252 /usr/sbin/apache2 -k start
           ├─19253 /usr/sbin/apache2 -k start
           ├─19255 /usr/sbin/apache2 -k start
           ├─19256 /usr/sbin/apache2 -k start
           ├─19268 /usr/sbin/apache2 -k start
           ├─19270 /usr/sbin/apache2 -k start
           ├─19276 /usr/sbin/apache2 -k start
           ├─19281 /usr/sbin/apache2 -k start
           └─19285 /usr/sbin/apache2 -k start

May 11 13:06:04 something.com apache2[16234]: Starting web server: apa...
May 11 13:06:04 something.com systemd[1]: Started LSB: Apache2 web se....
May 12 06:52:37 something.com systemd[1]: Reloading LSB: Apache2 web ....
May 12 06:52:38 something.com apache2[27533]: Reloading web server: ap...
May 12 06:52:38 something.com systemd[1]: Reloaded LSB: Apache2 web s....
Hint: Some lines were ellipsized, use -l to show in full.

apache2错误日志:

   [Thu May 12 06:52:38.198334 2016] [ssl:warn] [pid 16249] AH01906: something.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu May 12 06:52:38.198457 2016] [mpm_prefork:notice] [pid 16249] AH00163: Apache/2.4.10 (Debian) OpenSSL/1.0.1k configured -- resuming normal operations
[Thu May 12 06:52:38.198462 2016] [core:notice] [pid 16249] AH00094: Command line: '/usr/sbin/apache2'
[Thu May 12 16:31:43.877771 2016] [mpm_prefork:notice] [pid 16249] AH00169: caught SIGTERM, shutting down
[Thu May 12 16:31:44.905366 2016] [ssl:warn] [pid 1580] AH01906: something.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu May 12 16:31:44.925525 2016] [ssl:warn] [pid 1581] AH01906: something.com:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu May 12 16:31:44.926946 2016] [mpm_prefork:notice] [pid 1581] AH00163: Apache/2.4.10 (Debian) OpenSSL/1.0.1k configured -- resuming normal operations
[Thu May 12 16:31:44.926959 2016] [core:notice] [pid 1581] AH00094: Command line: '/usr/sbin/apache2'

网站配置:

<VirtualHost *:80>
        ServerAdmin webmaster@example.com
        ServerName  something.com
        ServerAlias www.something.com

        # Indexes + Directory Root.
        DocumentRoot /var/www/sitename/public_html/

         <Directory /var/www/sitename/public_html/>
                DirectoryIndex index.php
                Options indexes FollowSymLinks
                AllowOverride all
                Require all granted
        </Directory>

        # Logfiles
     ErrorLog /home/Glausten/website/sitename/logs/sitename_error_logs.log
     CustomLog /home/Glausten/website/sitename/logs/sitename_access_logs.log common
</VirtualHost>

#<VirtualHost *:80>
#        ServerAdmin webmaster@localhost
#        ServerName something.com
#        DocumentRoot /var/www/sitename/public_html/
#
#</VirtualHost>
#
#
#<IfModule mod_ssl.c>
#<VirtualHost *:443>
#
#        ServerAdmin something@gmail.com
#        ServerName something.com
#        DocumentRoot /var/www/sitename/public_html/
#
        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
#        SSLEngine on

        #   A self-signed (snakeoil) certificate can be created by installing
        #   the ssl-cert package. See
        #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
        #   If both key and certificate are stored in the same file, only the
        #   SSLCertificateFile directive is needed.
#        SSLCertificateFile /etc/apache2/ssl/apache.crt
#        SSLCertificateKeyFile /etc/apache2/ssl/apache.key
#</VirtualHost>

#</IfModule>

我还可以发布任何其他内容来帮助找到问题吗?

====================!=!=!===================== < / p>

我可能找到了问题

注意到错误日志中出现了一个新错误:

server reached MaxRequestWorkers setting
然后我开始谷歌并在这个网站上受伤:

http://cloudinservice.com/tune-apache-performance-using-mpm-prefork-module/ 这给了我一些关于mpm-prefork-module

中发生的事情的一些看法

然后我注意到MaxConnectionsPerChild设置为0意味着如果我有一些内存泄漏的PHP脚本将继续增长并消耗更多的内存而不释放任何时间这解释了为什么服务器突然下降我已经根据我的资源修改了文件并重新启动了apache。

我将会看到接下来几天的情况如何,如果它崩溃了,我会回来发布这个作为答案。

2 个答案:

答案 0 :(得分:1)

您似乎必须根据服务器配置配置apache。 我对数字海洋和他的小水滴也有同样的问题。 最好的方法是限制连接。但是,如果您可以提供有关日志,机器配置的更多信息,您应该得到更好的答案

答案 1 :(得分:0)

好的,因此根据您的硬件配置,可能是因为您使用的是小型服务器。 Digital ocean建议为微型机器创建一个apache的配置文件,允许15个子进程(假设apache为每个子进程使用10M)。您可以修改或创建/etc/apache2/apache2.conf

<IfModule mpm_prefork_module>
    StartServers          3
    MinSpareServers       3
    MaxSpareServers       5
    MaxClients           30
    MaxRequestsPerChild   0
</IfModule>

取自DigitalOcean

对于使用10 M的apache子进程和具有512M ram的服务器

,此配置已足够