【问题标题】:How to track down PHP crashes?如何追踪 PHP 崩溃?
【发布时间】:2012-06-12 21:38:16
【问题描述】:

我正在尝试追查我的 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.

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

【问题讨论】:

  • 从工作到现在有什么变化?
  • 它正在工作,只是随着负载的增加而崩溃。如果只是我测试,我基本上看不到问题。一旦它加载了 20 多个用户,那就是它开始出现问题的时候。但它仍然适用于他们,他们只是经常遇到通信错误(这可能意味着数据丢失)。
  • 6 月 8 日。这还在发生吗?
  • 是的,还在发生。我已经尝试禁用几个 php 扩展,将这些 dll 移动到 bin 或 system32,对代码进行了一些优化,这些都改善了事情,减少了崩溃的数量,但它仍然在发生。

标签: php mysql apache crash


【解决方案1】:

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

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

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

  • 自己编译 Apache(技术上可行,但在 Windows 上相当痛苦,据我记得)
  • 找到一个不是 XAMPP 的发行版,它是用 prefork 构建的(我不知道)

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

只是附注:我看不出在 Windows 服务器上安装 Apache 的意义。您可能需要考虑使用 IIS,可选择使用 FastGCI(请参阅说明 here),或者(更好地)切换到基于 Linux 的堆栈。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-30
  • 1970-01-01
  • 2012-06-08
  • 1970-01-01
  • 2018-05-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多