2017-05-04 5 views
0

윈도우의 PHP file_get_contents는 로컬 호스트

file_get_contents("http://127.0.0.1/test.php") 

처럼 아무것도 때 밖으로 나 또한 CURL과 재료를 사용하여 시도 한 번 어디 페소에 문제가 있어요

을에 504을 반환, 그것을 잘 작동합니다 다른 곳에서 데이터를받을려고하지만 로컬 호스트가 때 내가 Windows에서 10 64 PHP 버전 해요 (504)

을받을 것은 7.0.18 의 nginx 버전은 지금까지 1.8.0

입니다 I 모든 명령에 대한 설정 사용 권한을 시도했습니다. ctories, 나는 다른 사용자 에이전트 등을 시도했다, 심지어 내 크롬이 브라우저에서하는 것과 같은 요청을 복제하려했지만, 나는 운이 없다.

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" 

가 액세스하는 브라우저를 사용하는 경우
[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

가 잘 작동 php_errors.log에서 내가 얻을 PHP는 오류입니다. 나는 꽤 우둔한 사람이 나를 도울 수 있기를 바랍니다.

indexsss.php는 주석 처리 된 코드가 많이 포함되어 있습니다 (따라서 실행 행 번호는 ). 주석 처리되지 않은 코드 만 있습니다.

$test = file_get_contents("http://127.0.0.1/test.php");

test.php

"Hello, this is a test"

당신이 더 많은 정보가 필요하면 알려주세요.

답변

0

maximum_execution_time (기본값은 30 초)을 더 큰 값으로 설정하십시오. 예 : php.ini 파일에서 60 초. indexsss.php 스크립트를 최적화하는 것이 더 좋습니다.이 오류가 발생하기 때문입니다.

UPDATE :

<?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); 
?> 

http://php.net/manual/en/info.configuration.php#ini.max-execution-time

http://php.net/manual/en/function.stream-context-create.php

+0

안녕하세요, indexxx는이 문제가 아닙니다. 파일에 주석 처리 된 코드가 많이 포함되어 있습니다. 주석 처리되지 않은 유일한 행은 입니다.'$ test = file_get_contents ("http://127.0.0.1/test.php"); 모든 test.php는 다음과 같습니다. 문자열을 출력하므로 아무 것도 복잡하지 않습니다. 30 초 이상 걸리지 않아야합니다. –

+0

다음은 test.php의 내용입니다. – marmeladze

+0

나는 지금 막 위의 줄을 게시했다. ''안녕하세요, 시험입니다. '' –

0

이 구성된 모든 디버그 (Xdebug는 f.e.)을해야합니까. 그렇다면 동시 스레드를 지원하도록 구성해야합니다.

+0

이온 커브 로더가 전혀 없어도 상상할 수있는이 인스턴스에는 사용되지 않습니다. –