Problem description: a PHP script testdb to connect to a remote database. php, run: http: // localhost/testdb in the browser. php, error: Can't connect to MySQL server on '10. 60.56.220 '(13), but run php testdb locally. php, but normally connected to the database and read the data.
Application Environment: local IP Address: 10.60.56.90. Apache 2.2.3 and php 5.1.6 are installed on the local computer. The remote database server IP address is 10.60.56.220, the database is mysql 5.0.45, and the local and remote systems are centos 5.3.
The solution is entirely from idea:
Setsebool-P httpd_can_network_connect = 1
Of course, you must have the root permission on the http server, because only the root user can manage selinux.
For more information about selinux, see
Baidu Encyclopedia: http://baike.baidu.com/view/487687.htm
WIKI: http://en.wikipedia.org/wiki/Security-Enhanced_Linux
Selinux project: http://selinuxproject.org/page/Main_Page
Service parameters such as metadata, mysql, cvs, bind, scp, nfs, and samba.