Apache 会在每个星期天自动停止。为什么?

Alb*_*ana 1 centos6 apache-2.2

每个星期日 3 Apache 重新启动。问题是:服务器上有一个带有加密私钥的证书。由于在自动重启期间未提供密码,apache 停止并且我所有的网站都关闭了。

我想阻止 Apache 每周重新启动。如何?这是当时的apache日志。在[notice] caught SIGTERM, shutting down没有任何相关内容之前,如果您想知道...

[Sun Feb 15 03:37:12 2015] [notice] caught SIGTERM, shutting down 
[Sun Feb 15 03:37:12 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) 

[Sun Feb 15 03:37:13 2015] [error] Init: Unable to read pass phrase [Hint: key introduced or changed before restart?] 
[Sun Feb 15 03:37:13 2015] [error] SSL Library Error: 218529960 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag 
[Sun Feb 15 03:37:13 2015] [error] SSL Library Error: 218640442 error:0D08303A:asn1 encoding routines:ASN1_TEMPLATE_NOEXP_D2I:nested asn1 error 
[Sun Feb 15 03:37:13 2015] [error] SSL Library Error: 218529960 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag 
[Sun Feb 15 03:37:13 2015] [error] SSL Library Error: 218595386 error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error 
[Sun Feb 15 03:37:13 2015] [error] SSL Library Error: 67710980 error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib 
[Sun Feb 15 03:37:13 2015] [error] SSL Library Error: 218529960 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag 
[Sun Feb 15 03:37:13 2015] [error] SSL Library Error: 218595386 error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error 
[Sun Feb 15 11:09:41 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) 
[Sun Feb 15 11:09:44 2015] [notice] Digest: generating secret for digest authentication ... 
[Sun Feb 15 11:09:44 2015] [notice] Digest: done 
[Sun Feb 15 11:09:44 2015] [notice] FastCGI: wrapper mechanism enabled (wrapper: /usr/sbin/suexec) 
[Sun Feb 15 11:09:44 2015] [notice] FastCGI: process manager initialized (pid 11309) 
[Sun Feb 15 11:09:44 2015] [notice] Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/1.0.0-fips mod_fastcgi/2.4.6 configured -- resuming normal operations
Run Code Online (Sandbox Code Playgroud)

附加信息:

  • Cron 作业: /usr/sbin/raid-check这是唯一在周日晚上(凌晨 1 点)运行的 cron 作业,但是如果我手动运行它,Apache 不会发生任何事情......

Jak*_*sic 5

可能的原因是 logrotate 脚本中的后记。这就是在 logrotation 之后运行的脚本。文件应该被称为 /etc/logrotate.d/apache2 或 /etc/logrotate.d/httpd(取决于 od 发行版)并且看起来像:

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}
Run Code Online (Sandbox Code Playgroud)

相关部分是“服务 httpd 重新加载”。解决它的一种方法是删除最后 4 行(从共享脚本到结束脚本,包括那两行)。另外,添加 copytruncate 选项,因此您的 logrotate 脚本变为:

/var/log/httpd/*log {
    copytruncate
    missingok
    notifempty
}
Run Code Online (Sandbox Code Playgroud)

copytruncate 将消除重新启动 apache 的需要,因为它会复制日志文件的内容,然后将其归零,因此文件描述符将保持不变,并且 apache 进程不会注意到任何更改。

要测试 logrotate,请运行:

logrotate -f /etc/logrotate.d/httpd
Run Code Online (Sandbox Code Playgroud)

另外,考虑设置没有密码的私钥,因为这是不好的做法,很明显你现在明白为什么:)