Windows php文件\u get\u内容在本地主机上返回504

Windows php文件\u get\u内容在本地主机上返回504,php,curl,nginx,fastcgi,http-status-code-504,Php,Curl,Nginx,Fastcgi,Http Status Code 504,我对PhP有一个问题,它在执行类似操作时超时 file_get_contents("http://127.0.0.1/test.php") 我也尝试过使用CURL之类的东西,当我试图从其他地方接收数据时,它工作得很好,但是当它是本地主机时,我得到了一个504 我使用的是Windows10x64 Php版本是7.0.18 nginx版本是1.8.0 到目前为止,我已经尝试了所有目录的设置权限,我尝试了不同的用户代理等等,我甚至尝试了在浏览器中复制与我的chrome相同的请求,但我运气不好 我在e

我对PhP有一个问题,它在执行类似操作时超时

file_get_contents("http://127.0.0.1/test.php")
我也尝试过使用CURL之类的东西,当我试图从其他地方接收数据时,它工作得很好,但是当它是本地主机时,我得到了一个504

我使用的是Windows10x64 Php版本是7.0.18 nginx版本是1.8.0

到目前为止,我已经尝试了所有目录的设置权限,我尝试了不同的用户代理等等,我甚至尝试了在浏览器中复制与我的chrome相同的请求,但我运气不好

我在error.log中得到这个nginx错误

2017/05/04 10:26:33 [error] 7732#5384: *5 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 connecting to upstream, client: 127.0.0.1, server: _, request: "GET /test.php HTTP/1.0", upstream: "fastcgi://[::1]:9123", host: "127.0.0.1"
这是我从access.log获得的信息

127.0.0.1 - - [04/May/2017:10:25:33 +0200] "GET /indexsss.php HTTP/1.1" 504 584 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36"
127.0.0.1 - - [04/May/2017:10:25:33 +0200] "GET /favicon.ico HTTP/1.1" 404 570 "http://127.0.0.1/indexsss.php" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36"
127.0.0.1 - - [04/May/2017:10:26:33 +0200] "GET /test.php HTTP/1.0" 504 182 "-" "PHP"
这是我从php_errors.log获得的php错误

[04-May-2017 10:26:33 Europe/Copenhagen] PHP Warning:  file_get_contents(http://127.0.0.1/test.php): failed to open stream: HTTP request failed!  in C:\Servers\nginx-1.8.0\html\local\indexsss.php on line 208
[04-May-2017 10:26:33 Europe/Copenhagen] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in C:\Servers\nginx-1.8.0\html\local\indexsss.php on line 208
使用浏览器访问它时工作正常。所以我很无知,我希望有人能帮我

php包含大量注释代码(因此执行的行号) 唯一未注释的代码是这个

$test=文件获取内容(“http://127.0.0.1/test.php");

test.php

“您好,这是一个测试”


如果您需要更多信息,请告诉我。

最大执行时间
(默认为30秒)设置为更大的值-例如,从php.ini文件中设置60秒。或者更好地优化
indexss.php
脚本,因为它会导致此错误

更新:



您是否配置了任何调试(xdebug f.e.)。如果是,您需要将其配置为支持同时线程。

Hi,indexx不是问题所在。文件只是包含了很多注释掉的代码,唯一没有注释的行是
$test=File\u get\u contents(“http://127.0.0.1/test.php");“你好,这是一个测试”
我曾经遇到过这样的问题。然后添加了一个流上下文,它突然被修复了。我将用流示例更新我的答案。我只是尝试了
stream\u context\u create
,但并没有令人遗憾地解决它。仍然返回504。然而,我无法在我的debian vm上复制该问题,因此我可能必须再次检查所有配置文件。完全不是这样,我有一个ioncube加载程序,但我想象它不会在这个实例中使用。
<?php
$options = ['http'=>[
    'method'=>"GET",
    'header'=>"Accept-language: dk\r\n"
  ]
];

$ctx = stream_context_create($options);

$test = file_get_contents('http://127.0.0.1/test.php', false, $ctx);
?>