向apache调度请求时出错

req*_*nce 12 php apache lamp proxy dispatch

我在Google上有云托管,说实话它很糟糕,但我想继续使用它,我在VM上安装LAMP堆栈并将我的网站放在htdocs中.当我试图访问我的网站时它给了我 request timeout但有时它工作了5分钟左右.

当我看到apache错误日志时,它给了我这个

075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:55.185819 2015] [proxy_fcgi:error] [pid 4995:tid 140183521683200] (70007)The timeout specified has expired: [client 162.158.255.169:34198] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:55.487458 2015] [core:notice] [pid 2953:tid 140183785137920] AH00052: child pid 4995 exit signal Segmentation fault (11)
[Tue Oct 27 18:12:55.787973 2015] [proxy_fcgi:error] [pid 5063:tid 140183530075904] (70007)The timeout specified has expired: [client 199.27.133.137:13151] AH01075: Error dispatching request to : (polling), referer: http://whichtube.com/watch/g9-4dCeFQng/allama-nasir-abbas-jawab-ali-as-nae-talwar-kayou-na-uthai.html
[Tue Oct 27 18:12:57.542883 2015] [proxy_fcgi:error] [pid 5329:tid 140183521683200] (70007)The timeout specified has expired: [client 173.245.56.198:51348] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:57.976752 2015] [proxy_fcgi:error] [pid 5063:tid 140183479719680] (70007)The timeout specified has expired: [client 173.245.56.198:63779] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:58.993666 2015] [proxy_fcgi:error] [pid 5194:tid 140183496505088] (70007)The timeout specified has expired: [client 162.158.255.141:16226] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:12:59.196701 2015] [proxy_fcgi:error] [pid 5329:tid 140183513290496] (70007)The timeout specified has expired: [client 173.245.56.198:32819] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:01.462039 2015] [proxy_fcgi:error] [pid 5329:tid 140183504897792] (70007)The timeout specified has expired: [client 199.27.128.166:48057] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:07.518999 2015] [proxy_fcgi:error] [pid 5063:tid 140183471326976] (70007)The timeout specified has expired: [client 173.245.56.198:13694] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:16.804990 2015] [proxy_fcgi:error] [pid 5261:tid 140183513290496] (70007)The timeout specified has expired: [client 199.27.128.134:28694] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:33.055860 2015] [proxy_fcgi:error] [pid 5328:tid 140183236331264] (70007)The timeout specified has expired: [client 39.41.139.220:52154] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:57.391361 2015] [proxy_fcgi:error] [pid 5063:tid 140183521683200] (70007)The timeout specified has expired: [client 39.41.139.220:52029] AH01075: Error dispatching request to : (polling)
[Tue Oct 27 18:13:57.552542 2015] [core:notice] [pid 2953:tid 140183785137920] AH00052: child pid 5063 exit signal Segmentation fault (11)
Run Code Online (Sandbox Code Playgroud)

我的网站是用PHP编写的,除了目录权限之外,我没有更改任何其他内容,是否有我遗漏的内容?

Rob*_*dán 12

我遇到了同样的问题,原来 Apache 有处理超时的模块,称为mod_reqtimeout

默认值(您不会在默认的 http.conf 中看到它)是:

RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500
Run Code Online (Sandbox Code Playgroud)

就我而言,我是通过纯 HTML 表单提交上传文件,因此该文件在技术上是标题的一部分,默认配置表示标题将在 20 到 40 秒时超时。20-40 的事情非常酷,因为它会在 20 秒时超时,但是如果在 1 秒内发送 500 个字节,它将增加一秒的等待时间,直到达到 40 秒,然后无论如何都会超时。

我在我的网站上上传了更大的文件,所以我将此行添加到我的 httpd.conf 文件中:

RequestReadTimeout handshake=0 header=20-600,MinRate=500 body=20,MinRate=500
Run Code Online (Sandbox Code Playgroud)

因此,只要我的用户以至少 500 字节/秒的速度发送数据,请求就不会超时,直到达到最大值。达到 600 秒(最好阅读文档,不要引用我的吞吐率)

它实际上是一个非常酷的 Apache 模块,但并不是众所周知,因为人们建议在其他类似的“指定的超时已过期:”问题中更改其他 apache 超时设置,但与 PHP-FPM 相关的问题发生在任何超过 40 的帖子中在 Apache 中默认提交的秒数。


Tim*_*Tim 5

看起来您的 PHP 代码需要比配置的超时时间更长的时间才能完成。当 apache 使用 fcgi 加载 PHP 页面时,它会将请求发送到 PHP-FPM 服务以进行处理。如果 PHP-FPM 响应时间过长,您将看到这种类型的超时。可能的原因是;您的 PHP 代码可能陷入循环中,或者等待来自数据库的响应耗时特别长。

为了排除故障,我将使用 CLI 版本的 php 来查看脚本是否在合理的时间内完成($ time php /path/to/file.php)。PHP-FPM 日志中可能有其他信息(默认:/var/log/php-fpm.log)。


小智 5

对我来说,重新启动 php-fpm 就完成了这项工作。按照@varlogtim 的建议查看日志后。日志显示过去 12 小时没有活动...