天天看点

win7下php7.1运行getenv('REMOTE_ADDR')fastcgi停止运行

```

 // 本地环境phpStudy, PHP7.1.13nts+nginx,切换Apache也不行

//ps:php版本<=7.0正常

echo "<pre>";

// $_SERVER获取,正常

var_dump($_SERVER['SERVER_PORT']);

// 获取其他环境变量,正常

var_dump($_SERVER['REMOTE_ADDR']);

// 第二个参数设为true,正常

var_dump(getenv('REMOTE_ADDR', true));

// 崩溃,直接报fastcgi停止运行

var_dump(getenv('REMOTE_ADDR'));

win7下php7.1运行getenv('REMOTE_ADDR')fastcgi停止运行

Nginx 错误日志

2018/07/20 11:54:13 [error] 10192#8652: *1 WSARecv() failed (10054: An

existing connection was forcibly closed by the remote host) while

reading response header from upstream, client: 127.0.0.1, server:

localhost, request: "GET / HTTP/1.1", upstream:

"fastcgi://127.0.0.1:9000", host: "127.0.0.1"

分割线

================================================================================================

查阅php手册发现正好php7.1.13和7.2.10有此问题,本地环境恰好是这两个版本,更换版本即可。

win7下php7.1运行getenv('REMOTE_ADDR')fastcgi停止运行

非学,无以致疑;非问,无以广识

继续阅读