How to connect php to a remote database server in apache

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.