在问答提了个问题,但是还是觉得在论坛里说说比较好https://ask.csdn.net/questions/751179
在win10 安装了php+nginx+mysql,phpinfo打印是正常的,但是在写了一个简单的socket的demo后,nginx一直报超时。
写个简单的页面,phpinfo()执行都是没问题的,就是使用socket的时候什么错也不报,就是一直转,也不是keep-alive。$fp = fsockopen('localhost',80,$errno,$errstr,10); // 10秒超时
if (!$fp) {
    echo 'Error Code:'.$errno. '--Error Info:'.$errstr;
    die;
}
$http= '';
$http .= "GET /socket/server.php HTTP/1.1\r\n";$http .= "Host: localhost\r\n";
$http .= "Connection: close\r\n\r\n";fwrite($fp, $http);
$res = '';
while(!feof($fp)) {
    $res .= fgets($fp);
}
echo $res;
php代码应该没问题,我用apache就正常。nginx报错如下:查了nginx的日志:
2019/03/07 00:46:18 [error] 18316#16624: *1 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 /socket/client.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1"实在不知道咋回事,恳请各路大神指点迷津

解决方案 »

  1.   

    你换成apache ,或者在linux下就可以win+nginx  自己请求自己好像是有问题(具体啥原因我也没深究)
      

  2.   

    apache是正常的,我试过了,所以才感觉好奇怪,不过你这么一说win+nginx自己请求自己有问题,我好想也在哪里见过
      

  3.   

    apache是正常的,我试过了,所以才感觉好奇怪,不过你这么一说win+nginx自己请求自己有问题,我好想也在哪里见过
    所以没啥问题,有兴趣你可以研究一下,研究完了给我讲一下