Windows下的PHP的file_get_contents在localhost
file_get_contents("http://127.0.0.1/test.php")
做任何事情的時候,我還使用curl和東西嘗試
返回504,它工作正常,當我試圖從其他地方收到的數據,但是當它的本地主機,我收到了504
我在Windows上是10 64 PHP版本是7.0.18 nginx的版本是1.8.0
到目前爲止,我已經嘗試了所有可怕的設置權限ctories,我已經嘗試了不同的用戶代理等,我甚至試圖複製了同樣的要求作爲我的Chrome瀏覽器的做法,但我的運氣。
我得到這個nginx的錯誤error.log中。
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
http://127.0.0.1/test.php是使用瀏覽器訪問它時工作正常。所以我很無能,我希望有人能幫助我。
indexsss.php包含大量的註釋代碼(因此執行的行數) 唯一的未註釋的代碼是這樣的。
$test = file_get_contents("http://127.0.0.1/test.php");
test.php的
"Hello, this is a test"
讓我知道如果你需要更多的信息。
嗨,indexxx是不是這個問題。文件僅僅是包含了很多的註釋掉了代碼,而不是評論的唯一線路 '$測試=的file_get_contents(「http://127.0.0.1/test.php」);' 和所有的test.php確實是輸出一個字符串,所以並不複雜。不應該超過30秒。 –
然後test.php裏面有什麼? – marmeladze
我剛剛發佈了上面的一行。 '「你好,這是一個考驗」' –