Apache PHP unable connect remote MySQL
Recently I am setup a new server for one of my company client.
After finish configure the server & I am trying to setup SugarCRM inside the server, I found that the database connection part is not able to connect to a remote database server.
Then I try to fill in database information to local database server & everything is working fine.
Then I googled a while & found that it is a SELinux issue. It seem like block apache connect to a remote database server.
Below is my solutions:
- First, verify the SELinux is enabled. Code: [root@www ~]# getenforce You should see something back that looks like Enforcing
- If you see a different result, try: [root@www ~]# setenforce 1 If you get an error, then you do not have SELinux turned on. You will need to go to /etc/selinux/config and edit the file to enable SELinux. Once you turn this on (or turn it off for that matter) you will have to reboot the linux server for the chagnes to take effect as they are done during the kernel loading.
- Once SELinux is enabled, do the following Set SELinux to allow remote connections for HTTP [root@www ~]# setsebool -P httpd_can_network_connect=1
- Thats it! Your all done. Some people like to reboot to force a reload, but its not necessary unless you want to.