天天看點

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停止運作

非學,無以緻疑;非問,無以廣識

繼續閱讀