如何追踪PHP崩溃?

如何追踪PHP崩溃?,php,mysql,apache,crash,Php,Mysql,Apache,Crash,我正试图找出Apache PHP崩溃的原因。我希望有某种设置、工具或其他东西来帮助跟踪导致这些php崩溃的代码、配置或问题 在我的Windows事件日志中(显示apache崩溃,但由php引起): 该应用程序在WindowsServer2008机器(xampp)上使用Apache、PHP和MySQL 这是我的Apache日志中的崩溃: [Fri Jun 08 15:56:34 2012] [notice] Parent: child process exited with status 3221

我正试图找出Apache PHP崩溃的原因。我希望有某种设置、工具或其他东西来帮助跟踪导致这些php崩溃的代码、配置或问题

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

该应用程序在WindowsServer2008机器(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)是使用MPM(多线程)+线程安全PHP构建的,可能是您遇到了假定的线程安全版本的PHP固有的问题(有关更多信息,请参阅)。这可以解释为什么在单用户模式下运行时从未遇到错误

请让我们知道Uku Loskit的建议是否有用。如果不是,我建议在这样的多用户环境中切换到Prefork+非线程安全的PHP设置

由于MPM必须在编译时选择,因此您需要:

  • 自己编译Apache(在技术上是可行的,但据我记忆所及,在Windows上这是一件非常麻烦的事情)
  • 查找除XAMPP以外的发行版,该发行版是使用prefork构建的(我不知道任何发行版)
也许您最好尝试使用运行PHP(这个额外的层基本上通过为每个线程启动单独的PHP进程来隔离服务器线程,并且)。这应该可以让你很容易地验证我最初的假设


只是附带说明:我不认为在Windows服务器上安装Apache有什么意义。您可能想考虑使用IIS,可选地使用FastGCI(参见说明),或者(更好)切换到基于Linux的堆栈。

这可能有助于在工作和现在之间发生了什么变化?它正在工作,它只是随着负载的增加而崩溃。如果只是我在测试,我基本上看不到任何问题。一旦它加载了20多个用户,就开始出现问题。但这仍然适用于他们,他们只是偶尔会收到一次通信错误(这可能意味着数据丢失)。这还在发生吗?是的,还在发生。我已经尝试过禁用几个php扩展,将这些dll移动到bin或system32,对代码进行了一些优化,这些都改善了情况,减少了崩溃的数量,但这仍然在发生。我喜欢你的答案,不过我怎么知道这是否真的是MPM/线程安全的php问题呢(如果关闭MPM可以解决这个问题,那么如何在Apache Windows中关闭MPM,或者是否有其他推荐的解决方法)?我找到了这篇文章,其中有另外两个关于线程安全php问题的链接:另一个:
[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.