php - 使用 php 和 apache 意外重置服务器

标签 php mysql apache debugging

我有一个与数据库交互的应用程序。突然间,网页偶尔会在我的 Web 浏览器中显示 Server connection Reset 错误。更令人惊讶的是,在 localhost 页面上访问会触发 avast 上的警报。

如果我使用 Ctrl+R 刷新页面,它偶尔会发生。 PHP 没有显示任何错误消息,服务器似乎比平时花费更多的时间来响应。

我在 apache 2.4、PHP 5.4.3 中使用 wamp。我不知道从哪里开始调试或问题出在哪里。

[Sun May 13 13:01:14 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun May 13 13:01:14 2012] [notice] Apache/2.2.22 (Win32) mod_ssl/2.2.22 OpenSSL/0.9.8x configured -- resuming normal operations
[Sun May 13 13:01:14 2012] [notice] Server built: May 13 2012 12:51:11
[Sun May 13 13:01:14 2012] [notice] Parent: Created child process 3660
Apache server interrupted...
arn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun May 13 13:01:15 2012] [notice] Child 3660: Child process is running
[Sun May 13 13:01:15 2012] [notice] Child 3660: Acquired the start mutex.
[Sun May 13 13:01:15 2012] [notice] Child 3660: Starting 64 worker threads.
[Sun May 13 13:01:15 2012] [notice] Child 3660: Starting thread to listen on port 80.
[Sun May 13 13:01:15 2012] [notice] Child 3660: Starting thread to listen on port 80.
[Sun May 13 13:01:28 2012] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Sun May 13 13:01:28 2012] [notice] Child 3660: Exit event signaled. Child process is ending.
[Sun May 13 13:01:29 2012] [notice] Child 3660: Released the start mutex
[Sun May 13 13:01:30 2012] [notice] Child 3660: All worker threads have exited.
[Sun May 13 13:01:30 2012] [notice] Child 3660: Child process is exiting
[Sun May 13 13:01:30 2012] [notice] Parent: Child process exited successfully.

更新:

如果使用 cachegrind,当发生“连接请求”时,它会显示方法调用堆栈的部分列表。意味着它不会运行所有代码。它显示了一些 require_once 调用和它。下次如果我重试获取页面,页面将执行并显示整个调用堆栈。

当“发生连接请求”时显示

18 different functions called in milliseconds (1 runs, 18 shown)

重试后

220 different functions called in 329 milliseconds (2 runs, 220 shown)

我不知道为什么显示 2 次运行。执行页面也需要更多时间。不到 100 毫秒。

最佳答案

  1. 重新启动计算机并关闭/禁用所有正在运行的应用程序,包括防病毒软件,只保留最少的一组正在运行的应用程序。关闭一切,甚至是那些您确定不会干扰的应用程序——您永远不知道......

  2. 确保 PHP 显示所有错误/警告:

    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    

确保查看从 PHP 收到的每条警告。它可能会给您一些线索。

  1. 尝试隔离问题。注释一段您怀疑会导致问题的代码。继续评论直到停止收到错误。然后开始取消注释,直到找到有问题的地方。通过这种方式,您可以隔离有问题的代码,一旦您看到它,您就可以理解问题所在。

  2. 添加大量将写入日志文件(或只是回显)的语句。然后您可以分析日志文件并了解发生错误的时间点,帮助您隔离问题...

最终您会找到有问题的代码块,并且能够跟踪问题。希望 :)

关于php - 使用 php 和 apache 意外重置服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15988602/

相关文章:

php - 有没有办法在使用联系表 7 付款后重定向到特定的感谢页面?

javascript - 调用 $.getJSON 并发送 URL 参数

java - jsp在表单上控制服务器端

apache - 301 重定向到没有 .htaccess (myshopify.com) 和 SEO 排名问题的站点

php - 在不更改 777 权限的情况下使用 Apache + PHP 发送邮件的权限错误

javascript - 如何使用 apache2 为我的 Linux 网络服务器上的音频文件设置 CORS 访问权限?

php - 重命名并替换我的图像文件夹 php 中的图像

php - 如何将PHP排序替换为SQL?

php - 在mysql中选择一列值

mysql - 照片存储难题