如何追踪PHP崩溃?

我试图找出我的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.

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

最佳答案 由于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的堆栈.

点赞