Today's work encountered problems, the new Linux server, PHP, Apache and a series of extensions installed, in the local good program moved up to hold the database connection error, but with the SQL command can connect up,
Make a simple Judgment database Connection page or not, prove not a program problem, but the PHP where the problem, on the Internet to check the majority of days some methods are not the case after the accident found SELinux this thing
Check this out. Restricted access to external httpd;
Input command: Getsebool-a|grep-i httpd
There's going to be a httpd_can_network_connect---off of this stuff.
Off is equal to the permission to open httpd external access, to be set to on.
Method 1: Direct input command: Setsebool-p httpd_can_network_connect=1, re-command: Setenforce 0
Method 2:vim/etc/sysconfig/selinux
There's a line #SELINUX =enforcing instead: selinux=disabled, re-order: Setenforce 0
SELinux causes PHP connection to MySQL exception solution for can ' t connect to MySQL server