## 1.CentOS+Apache+php無法訪問redis的解決方法 Redis server went away
在網上查該異常時均認為是php的Sokcet超時時間設置的過短,應該在代碼前加上:
```
<?php
ini_set('default_socket_timeout', -1);
?>
```
經測試仍無法解決該問題,因在代碼后臺運行正常,因此判斷并非代碼本身問題,而是Apache不允許訪問網絡資源,嘗試如下解決方法:打開/etc/selinux/config,找到其中的:
```
SELINUX=enforcing
改為:
SELINUX=disabled
```
問題解決!
如果仍不能解決問題,可執行如下指令:
```
/usr/sbin/setsebool httpd_can_network_connect=1
```
## 2.protocol error, got 'n' as reply type byte
在redis配置文件redis.conf中注釋掉bind配置項的,同時把redis3.2新增的配置項
```
protected-mode由yes改為no,
```
改完后重啟redis服務