转自于http://www.cnblogs.com/ayanmw/p/3464121.html
CentOS 下thinkPHP连接数据库时,提示Can't connect to MySQL server on '127.0.0.1' (13),上网搜索资料,http://www.cnblogs.com/ayanmw/p/3464121.html发现这篇文章,经测试完美解决。
原因:
#getsebool -a | grep httpd
[neo@neo phpMyTest]$ getsebool -a | grep httpd
发现 httpd_can_network_connect --> off
解决方案:
#setsebool httpd_can_network_connect 1
原来是 SELINUX,所以我一般直接关闭SELINUX和 iptables ip6tables
# 关闭SELINUX
chkconfig --level 12345 iptables off
chkconfig --level 12345 ip6tables off
service iptables stop
service ip6tables stop
查看SELinux状态:
1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态
SELinux status: enabled
2、getenforce ##也可以用这个命令检查
关闭SELinux:
1、临时关闭(不用重启机器):
setenforce 0 ##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
2、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled