nginx php file_get_contents('本地虚机') 超时
巴扎黑
巴扎黑 2017-04-10 16:45:53
0
2
460

CGI 阻塞 如何解决。棘手。

2016/02/05 10:59:35 [error] 6496#4544: *3 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"

巴扎黑
巴扎黑

reply all(2)
PHPzhong

贴一下详细的报错信息啊

左手右手慢动作

我们再来试验在index.php中加入file_get_contents(‘http://127.0.0.1/phpinfo.php’)语句向phpinfo.php发送一个请求,这时浏览器中的状态指示一直在打转,表示它一直在工作中。打开Dos中的netstat命令,可以看到本地的9000端口的状态为:ESTABLISHED,表示该进程在联机处理中。实际上,这里我们已经同时向nginx发送了两个基于http的php请求,一个是解析index.php,而另一个是phpinfo.php,这样矛盾就出来了,因为我们的windows系统只加载了一个http进程,因此,它无法同时处理两个php请求,它只能先处理第一个请求(index.php),而index.php却又在等待phpinfo.php处理结果,phpinfo.php没人帮它处理请求,因为它一直在等待index.php释放结束信号,因此,造成了程序的阻塞状态,陷入了死循环。

解决方法:
nginx.conf 里面 对不同server 修改fastcgi_pass的端口号

   fastcgi_pass   127.0.0.1:9000;
   fastcgi_pass   127.0.0.1:9001;

windows下nginx+fastcgi不能使用file_get_contents/curl/fopen的原因

windows下PHP + Nginx curl访问本地超时

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!