php Apache proxfy_fcgi - 将请求分派到

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33375823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:27:53  来源:igfitidea点击:

Apache proxfy_fcgi - Error dispatching request to

phpapacheproxylampdispatch

提问by require_once

I have cloud hosting on Google, it sucks for to be honest but I am trying to get on with it, I installed LAMP stack on a VM and put my website in htdocs. When I try to access my site it gives me request timeoutbut sometimes it works for 5 minute or so.

我在 Google 上有云托管,老实说这很糟糕,但我正在努力解决它,我在 VM 上安装了 LAMP 堆栈并将我的网站放在 htdocs 中。当我尝试访问我的网站时,它给了我, request timeout但有时它会工作 5 分钟左右。

When I see apache error logs , it gives me this

当我看到 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)

My website is in PHP, I haven't changed anything else other than directory permission, Is there something I am missing ?

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

回答by Roberto Ibarra Rabadán

I was having the same problem, turns out Apache has module that handles timeouts called mod_reqtimeout

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

The default value (you won't see it in the default http.conf) is:

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

RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500

In my case I was uploading a file through a plain HTML form submission, so the file is technically part of the header and the default configuration says that the header will timeout at 20 to 40 seconds. The 20-40 thing is pretty cool because it will timeout at 20 seconds but if 500 bytes are sent in a second, it will add an additional second of wait time until it reaches 40 seconds and then timeout no matter what.

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

I upload larger files in my website so I added this line to my httpd.conf file:

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

RequestReadTimeout handshake=0 header=20-600,MinRate=500 body=20,MinRate=500

So as long as my user is sending data at a minimum of 500 bytes/s, the request will not time out until a max. of 600 seconds is reached (better read the documentation, don't quote me on the throughput rate)

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

It's actually a pretty cool Apache module but not super well known as people recommend to change other apache timeout settings in other similar "The timeout specified has expired:" problems related to PHP-FPM but this problem happens with any post that takes more than 40 seconds to be submitted by default in Apache.

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

回答by Saeed Sepehr

I had this problem, too. You may want to looking for a hard-code part and a connection to another unavailable server, in your code. (for example a local IP which is not accessible online).

我也有这个问题。您可能希望在您的代码中查找硬编码部分和到另一个不可用服务器的连接。(例如无法在线访问的本地 IP)。

For mine, I checked php-fpm.log on my server and I found my application is trying to connect to an old server (wrong IP) and it faces with timed out.

对于我的,我检查了我的服务器上的 php-fpm.log,我发现我的应用程序正在尝试连接到旧服务器(错误的 IP)并且它面临超时。

回答by David

For me a restart of php-fpm did the job. After looking in the log as @varlogtim adviced. The log showed that there was no activity for the last 12 hours...

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

回答by varlogtim

It appears that your PHP code is taking longer than the configured timeout to complete. When apache loads a PHP page using fcgi it sends the request of to PHP-FPM service to be processed. If PHP-FPM takes to long to respond then you will see this type of timeout. Possible causes are that your PHP code could be stuck in a loop or waiting on a response from a database that is taking a particularly long time.

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

To troubleshoot I would use the CLI version of php to see if the script completes in a reasonable amount of time ($ time php /path/to/file.php). There may additional information in the PHP-FPM log (default: /var/log/php-fpm.log).

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