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

var*_*uog 7 php mysql apache debugging

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

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

我正在使用apache 2.4,PHP 5.4.3.关于从何处开始调试或问题出在哪里,我一无所知.

[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.
Run Code Online (Sandbox Code Playgroud)

更新:

如果使用"连接请求",则cachegrind显示方法的callstack的部分列表.意味着它不会运行所有代码.它显示了一些require_once调用和它.下次如果我重试获取页面,页面执行并显示整个callstack.

当'连接请求发生'时,它显示

18 different functions called in milliseconds (1 runs, 18 shown)
Run Code Online (Sandbox Code Playgroud)

重试后

220 different functions called in 329 milliseconds (2 runs, 220 shown)
Run Code Online (Sandbox Code Playgroud)

我不知道它为什么显示2次运行.它还需要更多时间来执行页面.在它不到100毫秒之前.

Ale*_*uhl 0

要通过 PHP 重新启动 Apache,请在 PHP 中使用以下代码

exec('/etc/init.d/httpd graceful');
Run Code Online (Sandbox Code Playgroud)

并且查看手册...并将路径更改为您的httpd

  • 顺便说一句,如果您的服务器允许您通过调用通常需要由超级用户从其内部运行的任意脚本来重新启动它,我会非常害怕..) (2认同)