Apache自动停止每个星期日。 为什么?

3 Apache每周日重新启动。 问题是:服务器上有一个encryption私钥的证书。 作为在自动重启过程中没有提供的密码,apache会停下来,所有的网站都会closures。

我想停止每周重新启动Apache。 怎么样? 这是当时的apache日志。 在[notice] caught SIGTERM, shutting down之前[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 

附加信息:

  • Cron Jobs: /usr/sbin/raid-check这是在周日晚上(1AM)运行的唯一的cron作业,但是如果我手动运行它,Apache没有任何事情发生…

可能的原因是logrotate脚本中的postscript。 这就是在login后运行的脚本。 文件应该叫/etc/logrotate.d/apache2或/etc/logrotate.d/httpd(取决于发行版),看起来像这样:

 /var/log/httpd/*log { missingok notifempty sharedscripts postrotate /sbin/service httpd reload > /dev/null 2>/dev/null || true endscript } 

相关部分是“service httpd reload”。 解决这个问题的一个方法就是删除最后4行(从sharedscripts到endcript,包括那两个)。 另外,添加copytruncate选项,所以你的logrotate脚本变成:

 /var/log/httpd/*log { copytruncate missingok notifempty } 

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

要testinglogrotate,请运行:

 logrotate -f /etc/logrotate.d/httpd 

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