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

weixin_34015860發表於2018-09-06

```
 // 本地環境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'));

```


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有此問題,本地環境恰好是這兩個版本,更換版本即可。

相關文章