2017-04-06 5 views
-2

win7에 nginx1.10 및 php5.6을 설치했는데 PHP를 실행하면 동일한 포트 PHP 스크립트를 요청할 수 없습니다.PHP 오류 : 0 바이트로 35007 밀리 초가 경과 한 후 작업 시간이 초과되었습니다.

http://localhost/a.php 컬 요청 http://localhost/phpinfo.php, 오류 도움말 Error:Operation timed out after 35007 milliseconds with 0 bytes received.

server { 
    listen 80; 
    server_name localhost; 
    root d:/localhost; 
    index index.html index.htm index.php; 
    autoindex on; 
    autoindex_localtime on; 

    location ~ \.php$ { 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include  fastcgi_params; 
    } 
} 

http://localhost/a.php

<?php 
function makeRequest($url, $params, $method = 'GET') 
{ 
    $ch = curl_init(); 
    if ($method == 'GET') { 
     $url .= '?' . http_build_query($params); 
    } else { 
     curl_setopt($ch, CURLOPT_POST, 1); 
     curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 
    } 

    if (substr($url, 0, 6) == 'https:') { 
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
    } 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
    curl_setopt($ch, CURLOPT_USERAGENT, 'ApiClient/v1.0'); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 35); 


    $result = curl_exec($ch); 
    $info = curl_getinfo($ch); 
    $error = curl_error($ch); 

    curl_close($ch); 
    print_r($info); 
    var_dump($error); 
    return $result; 
} 


$url = 'http://localhost/phpinfo.php'; 
makeRequest($url, []); 

출력 :

Array 
(
    [url] => http://localhost/phpinfo.php? 
    [content_type] => 
    [http_code] => 0 
    [header_size] => 0 
    [request_size] => 96 
    [filetime] => -1 
    [ssl_verify_result] => 0 
    [redirect_count] => 0 
    [total_time] => 35.007 
    [namelookup_time] => 0.016 
    [connect_time] => 0.219 
    [pretransfer_time] => 0.219 
    [size_upload] => 0 
    [size_download] => 0 
    [speed_download] => 0 
    [speed_upload] => 0 
    [download_content_length] => -1 
    [upload_content_length] => -1 
    [starttransfer_time] => 0 
    [redirect_time] => 0 
    [redirect_url] => 
    [primary_ip] => 127.0.0.1 
    [certinfo] => Array 
     (
     ) 

    [primary_port] => 80 
    [local_ip] => 127.0.0.1 
    [local_port] => 55978 
) 

D:\localhost\a.php:37:string 'Operation timed out after 35007 milliseconds with 0 bytes received' (length=66) 

그러나

다른 포트를 사용하면 요청을 시작하는 PHP가 A 포트를 사용하고 요청의 PHP에 대한 응답이 다른 포트를 사용하고 실행 시간 초과가 발생하지 않는다는 것을 발견했습니다.

+0

php-cgi가 php-fpm이 아니기 때문에 php-cgi는 자동으로 새 프로세스를 시작하지 않으므로 일단 점유되면 잠겨집니다. – Mario7

답변

0

필자는 왜 php-cgi가 php-fpm이 아니기 때문에 php-cgi가 자동으로 새 프로세스를 시작하지 않기 때문에 점유 된 상태가 잠길 것입니다.