Product:
Search Type:

I have problem getting the PHP/Apache on the Plesk server to work with the external Mysql database. Connection from PHP scripts to the remote database always fails.

Article ID: 1682 
Last Review: Feb,07 2007
APPLIES TO:
  • Plesk for Linux/Unix

RESOLUTION

SYMPTOMS:

I have problem getting the PHP/Apache on the Plesk server to work with the external Mysql database. Connection from PHP scripts to the remote database always fails. However we can connect to the database server from SSH on the web server with "mysql -h hostname -u user -p". We made a small php script that simply tries to connect to the remote database. When running the php script in ssh on the web server it works just fine. But when running it under Apache we get a connection failure no matter what we do.

 

RESOLUTION:

Please check if selinux is enabled in the system. If yes, try to disable it as described in 1636 or allow remote connections for Apache with:

# setsebool -P httpd_can_network_connect=1

There are other selinux restrictions which can affect the server in the future. You can get the full list with the command 'getsebool -a'.

Keywords: remote connection from php script failed error

Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
*Please type the code you can see.
* - required fields