![Apache 突然无法启动](https://linux22.com/image/799454/Apache%20%E7%AA%81%E7%84%B6%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8.png)
我一直在 OS X 10.8.2 上使用多个虚拟主机。我使用 Apache2 安装和 MySQL 来运行基于名称的虚拟主机。它们一直运行良好,直到昨晚。突然,我的所有虚拟主机都重定向到“无法连接到”页面。
经过一番折腾,最后检查了错误日志,我得出结论,Apache 实际上并未运行。例如,ps aux | grep apache
仅返回 grep 进程。但是,如果我尝试,sudo /usr/sbin/apachectl start
则会得到“org.apache.httpd:已加载”的响应。
我检查了我的 httpd.conf 文件,它看起来完全正常。我看不到任何变化。我还运行了语法检查命令(当时我突然想不起来了),它返回了 OK。我在错误日志中发现的唯一一条信息(最后一条)来自昨天(2 月 21 日),上面写着:“[2013 年 2 月 21 日星期四 21:46:02] [通知] 捕获 SIGTERM,正在关闭”
从那时起,我的 Apache 错误日志就什么都没有了(因为它没有运行)。我重新启动了,尝试重新启动 Apache;我完全搞不懂为什么它认为它在运行,但实际上并没有。
有任何想法吗?
编辑
当我尝试启动并重新启动 Apache 时,在 /var/logs/system.log 中:
Feb 23 09:27:00 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8766]): Exited with code: 1
Feb 23 09:27:00 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:10 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8767]): Exited with code: 1
Feb 23 09:27:10 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:16 Baileys-MacBook-Pro.local sudo[8769]: bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/sbin/apachectl start
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8772]): Exited with code: 1
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:20 Baileys-MacBook-Pro.local sudo[8773]: bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/sbin/apachectl restart
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd[8777]): Exited with code: 1
Feb 23 09:27:20 Baileys-MacBook-Pro com.apple.launchd[1] (org.apache.httpd): Throttling respawn: Will start in 10 seconds
Feb 23 09:27:26 Baileys-MacBook-Pro.local sudo[8778]: bailey : TTY=ttys000 ; PWD=/private/var/log ; USER=root ; COMMAND=/usr/bin/vi system.log
~
编辑
我忘了说了——重启后这个问题仍然存在。从前几天开始,它就无法启动,但认为 httpd 模块已加载。
我试图通过 Google 查找答案,但是——有人知道 Apache 如何检查它是否已加载吗?我知道很多服务都会锁定文件以进行运行;Apache 是否可能在某个地方有一个锁定文件,尽管 Apache 当前未运行,但该文件仍处于锁定状态?
编辑
根据要求,这是 Apache 错误日志。由于它非常庞大,因此这是“sudo cat error_log | grep Feb > [a text file]”的结果,因此仅列出上个月的条目:
[Mon Feb 04 15:15:09 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 04 15:15:43 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Mon Feb 04 15:15:43 2013] [notice] Digest: generating secret for digest authentication ...
[Mon Feb 04 15:15:43 2013] [notice] Digest: done
[Mon Feb 04 15:15:43 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Mon Feb 04 20:26:41 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 04 20:27:17 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Mon Feb 04 20:27:17 2013] [notice] Digest: generating secret for digest authentication ...
[Mon Feb 04 20:27:17 2013] [notice] Digest: done
[Mon Feb 04 20:27:17 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Tue Feb 05 14:06:34 2013] [notice] caught SIGTERM, shutting down
[Tue Feb 05 14:07:08 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Feb 05 14:07:08 2013] [notice] Digest: generating secret for digest authentication ...
[Tue Feb 05 14:07:08 2013] [notice] Digest: done
[Tue Feb 05 14:07:08 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Tue Feb 05 15:25:16 2013] [notice] caught SIGTERM, shutting down
[Tue Feb 05 15:25:50 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Feb 05 15:25:50 2013] [notice] Digest: generating secret for digest authentication ...
[Tue Feb 05 15:25:50 2013] [notice] Digest: done
[Tue Feb 05 15:25:50 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Tue Feb 05 16:14:22 2013] [notice] caught SIGTERM, shutting down
[Tue Feb 05 16:14:52 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Feb 05 16:14:52 2013] [notice] Digest: generating secret for digest authentication ...
[Tue Feb 05 16:14:52 2013] [notice] Digest: done
[Tue Feb 05 16:14:52 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Sun Feb 10 19:47:52 2013] [notice] caught SIGTERM, shutting down
[Sun Feb 10 19:47:53 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Feb 10 19:47:53 2013] [notice] Digest: generating secret for digest authentication ...
[Sun Feb 10 19:47:53 2013] [notice] Digest: done
[Sun Feb 10 19:47:53 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Mon Feb 11 21:41:20 2013] [notice] caught SIGTERM, shutting down
[Mon Feb 11 21:41:53 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Mon Feb 11 21:41:53 2013] [notice] Digest: generating secret for digest authentication ...
[Mon Feb 11 21:41:53 2013] [notice] Digest: done
[Mon Feb 11 21:41:54 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Tue Feb 12 07:23:36 2013] [notice] caught SIGTERM, shutting down
[Tue Feb 12 07:24:05 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Feb 12 07:24:05 2013] [notice] Digest: generating secret for digest authentication ...
[Tue Feb 12 07:24:05 2013] [notice] Digest: done
[Tue Feb 12 07:24:05 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Tue Feb 12 12:49:02 2013] [notice] caught SIGTERM, shutting down
[Tue Feb 12 12:51:44 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Feb 12 12:51:44 2013] [notice] Digest: generating secret for digest authentication ...
[Tue Feb 12 12:51:44 2013] [notice] Digest: done
[Tue Feb 12 12:51:44 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Thu Feb 14 09:14:23 2013] [notice] caught SIGTERM, shutting down
[Thu Feb 14 09:14:23 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Feb 14 09:14:23 2013] [notice] Digest: generating secret for digest authentication ...
[Thu Feb 14 09:14:23 2013] [notice] Digest: done
[Thu Feb 14 09:14:23 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Thu Feb 14 09:14:38 2013] [notice] caught SIGTERM, shutting down
[Thu Feb 14 09:14:38 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Feb 14 09:14:38 2013] [notice] Digest: generating secret for digest authentication ...
[Thu Feb 14 09:14:38 2013] [notice] Digest: done
[Thu Feb 14 09:14:38 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Thu Feb 14 10:01:40 2013] [notice] caught SIGTERM, shutting down
[Thu Feb 14 10:02:15 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Feb 14 10:02:15 2013] [notice] Digest: generating secret for digest authentication ...
[Thu Feb 14 10:02:15 2013] [notice] Digest: done
[Thu Feb 14 10:02:15 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Thu Feb 14 12:42:40 2013] [notice] caught SIGTERM, shutting down
[Thu Feb 14 12:43:15 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Feb 14 12:43:15 2013] [notice] Digest: generating secret for digest authentication ...
[Thu Feb 14 12:43:15 2013] [notice] Digest: done
[Thu Feb 14 12:43:15 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Thu Feb 14 17:07:26 2013] [notice] caught SIGTERM, shutting down
[Thu Feb 14 17:07:27 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Feb 14 17:07:27 2013] [notice] Digest: generating secret for digest authentication ...
[Thu Feb 14 17:07:27 2013] [notice] Digest: done
[Thu Feb 14 17:07:27 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Sun Feb 17 16:54:37 2013] [notice] child pid 1248 exit signal Segmentation fault (11)
[Sun Feb 17 16:54:45 2013] [notice] child pid 2909 exit signal Segmentation fault (11)
[Sun Feb 17 16:54:52 2013] [notice] child pid 1247 exit signal Segmentation fault (11)
[Sun Feb 17 16:54:52 2013] [notice] child pid 1188 exit signal Segmentation fault (11)
[Sun Feb 17 16:54:55 2013] [notice] child pid 1190 exit signal Segmentation fault (11)
[Sun Feb 17 16:55:24 2013] [notice] child pid 3747 exit signal Segmentation fault (11)
[Sun Feb 17 16:55:50 2013] [notice] child pid 1246 exit signal Segmentation fault (11)
[Sun Feb 17 16:55:54 2013] [notice] child pid 3750 exit signal Segmentation fault (11)
[Sun Feb 17 17:00:00 2013] [notice] child pid 3751 exit signal Segmentation fault (11)
[Sun Feb 17 17:00:28 2013] [notice] child pid 3754 exit signal Segmentation fault (11)
[Sun Feb 17 17:01:03 2013] [notice] child pid 3756 exit signal Segmentation fault (11)
[Sun Feb 17 17:03:58 2013] [notice] caught SIGTERM, shutting down
[Sun Feb 17 17:03:59 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Feb 17 17:03:59 2013] [notice] Digest: generating secret for digest authentication ...
[Sun Feb 17 17:03:59 2013] [notice] Digest: done
[Sun Feb 17 17:03:59 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Sun Feb 17 17:04:10 2013] [notice] child pid 3778 exit signal Segmentation fault (11)
[Sun Feb 17 17:05:45 2013] [notice] child pid 3783 exit signal Segmentation fault (11)
[Sun Feb 17 17:05:48 2013] [notice] child pid 3782 exit signal Segmentation fault (11)
[Sun Feb 17 17:05:55 2013] [notice] child pid 3787 exit signal Segmentation fault (11)
[Sun Feb 17 17:05:58 2013] [notice] child pid 3788 exit signal Segmentation fault (11)
[Sun Feb 17 17:06:16 2013] [notice] child pid 3789 exit signal Segmentation fault (11)
[Sun Feb 17 17:06:49 2013] [notice] child pid 3791 exit signal Segmentation fault (11)
[Sun Feb 17 17:26:24 2013] [notice] child pid 3794 exit signal Segmentation fault (11)
[Sun Feb 17 17:26:28 2013] [notice] child pid 3793 exit signal Segmentation fault (11)
[Sun Feb 17 17:26:30 2013] [notice] child pid 3796 exit signal Segmentation fault (11)
[Sun Feb 17 17:26:32 2013] [notice] child pid 3806 exit signal Segmentation fault (11)
[Sun Feb 17 17:57:14 2013] [notice] caught SIGTERM, shutting down
[Sun Feb 17 17:57:52 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Feb 17 17:57:52 2013] [notice] Digest: generating secret for digest authentication ...
[Sun Feb 17 17:57:52 2013] [notice] Digest: done
[Sun Feb 17 17:57:52 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8r configured -- resuming normal operations
[Thu Feb 21 21:46:02 2013] [notice] caught SIGTERM, shutting down
答案1
如果无法写入日志文件,Apache 将拒绝启动。我曾在开发机器上安装过许多 Apache,原因是在 VirtualHost 中设置了如下指令:
TransferLog /path/to/sandbox/example.com/log/access.log
ErrorLog /path/to/sandbox/example.com/log/error.log
然后在某个时候我又这样做了,rm -r /path/to/sandbox/example.com
因为我不再需要它了。
答案2
老实说,我受够了,试图在我的计算机上重新安装 OS X,重新开始。我遇到了无法在 MBP 上重新安装的问题?甚至连 Apple 商店的员工都对此感到困惑。我要关闭它,因为我认为这实际上可能是某种硬件问题。他们不得不在我的 MacBook Pro 上完全擦除并重新安装才能解决这个问题。