centos7 centos中apache运行php需要连接mysql一直连不上,telnet访问mysql出错Connection closed by foreign host
执行命令:
getsebool -a|grep httpd
发现
httpd_can_network_connect off
解决:
setsebool httpd_can_network_connect 1 && setsebool httpd_can_network_connect_cobbler 1 && setsebool httpd_can_network_connect_db 1 && setsebool httpd_can_network_relay 1
需要重新启动httpd
systemctl restart httpd.service