如何追踪PHP崩溃?

时间:2012-06-08 20:06:21

标签: php mysql apache crash

我正在尝试追踪我的Apache PHP崩溃的原因。我希望有一些设置,工具或某些东西来帮助追踪导致这些php崩溃的代码,配置或问题。

在我的Windows事件日志中,我(显示apache崩溃,但由php引起):

Faulting application httpd.exe, version 2.2.21.0, time stamp 0x4e6b3136, faulting module php5ts.dll, version 5.3.8.0, time stamp 0x4e537a04, exception code 0xc0000005, fault offset 0x0000c7d7, process id 0xbf4, application start time 0x01cd45afc42f0b7d.

该应用程序在Windows Server 2008计算机(xampp)上使用Apache,PHP和MySQL。

这是我的Apache日志崩溃:

[Fri Jun 08 15:56:34 2012] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Fri Jun 08 15:56:35 2012] [notice] Digest: generating secret for digest authentication ...
[Fri Jun 08 15:56:35 2012] [notice] Digest: done
[Fri Jun 08 15:56:35 2012] [notice] Apache/2.2.21 (Win32) PHP/5.3.8 configured -- resuming normal operations
[Fri Jun 08 15:56:35 2012] [notice] Server built: Sep 10 2011 11:34:11
[Fri Jun 08 15:56:35 2012] [notice] Parent: Created child process 1220
[Fri Jun 08 15:56:35 2012] [notice] Digest: generating secret for digest authentication ...
[Fri Jun 08 15:56:35 2012] [notice] Digest: done
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Child process is running
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Acquired the start mutex.
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Starting 150 worker threads.
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Starting thread to listen on port 80.
[Fri Jun 08 15:56:35 2012] [notice] Child 1220: Starting thread to listen on port 80.
[Fri Jun 08 15:57:37 2012] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Fri Jun 08 15:57:37 2012] [notice] Digest: generating secret for digest authentication ...
[Fri Jun 08 15:57:37 2012] [notice] Digest: done
[Fri Jun 08 15:57:37 2012] [notice] Apache/2.2.21 (Win32) PHP/5.3.8 configured -- resuming normal operations
[Fri Jun 08 15:57:37 2012] [notice] Server built: Sep 10 2011 11:34:11
[Fri Jun 08 15:57:37 2012] [notice] Parent: Created child process 3932
[Fri Jun 08 15:57:38 2012] [notice] Digest: generating secret for digest authentication ...
[Fri Jun 08 15:57:38 2012] [notice] Digest: done
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Child process is running
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Acquired the start mutex.
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Starting 150 worker threads.
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Starting thread to listen on port 80.
[Fri Jun 08 15:57:38 2012] [notice] Child 3932: Starting thread to listen on port 80.

关于我应该尝试什么的任何想法,或者追溯到什么代码等的工具/技术可能会导致这种情况?

1 个答案:

答案 0 :(得分:2)

由于XAMPP的Apache(用于Windows)是使用winn_nt MPM(多线程)+线程安全的PHP构建的,因此可能是您遇到了所谓的PHP线程安全版本所固有的问题(有关更多信息,请参阅this very good post。这可以解释为什么在单用户模式下运行时从未遇到过错误。

如果Uku Loskit的建议有任何好处,请告诉我们。如果没有,我建议在这样的多用户环境中切换到Prefork + Non-Thread-Safe PHP设置。

因为必须在编译时选择MPM,所以你需要:

  • 自己编译Apache(技术上可行,但据我记得,在Windows的脖子上非常痛苦)
  • 找到XAMPP以外的发行版,它是用prefork构建的(我不知道)

也许您最好尝试使用FastCGI运行PHP(这个额外的层基本上通过为每个线程启动单独的PHP进程来隔离服务器线程,并much more)。这应该可以让你很容易地验证我的初始假设。

请注意:我没有看到在Windows Server上安装Apache的重点。您可能要考虑使用IIS,可选择使用FastGCI(请参阅说明here),或者(更好)切换到基于Linux的堆栈。