I have a unique setup for a web application that I need to get my head around.
I have two servers that will need to talk to each other. Server A will host the actual PHP-based application; Server B will host the MySQL database and the server connection details. Server B will also be within a closed network, so that only people on the local network will be able to access the server, whereas Server A will be web based.
If the visitor has access to the local network for Server B, they should then be able to, through the scripting on Server A, connect to and access the database on Server B to complete the picture.
My first question is: is this possible? I think it is, but I am not 100% sure.
Secondly: How would I write the script for accessing the Server B script? Is it similar to accessing an include file or would it be a remote HTTPS call? I’m just not sure how to go about making this happen.
Advertisement
Answer
Remotely connecting to a MySQL database should be no problem. Here is a pretty thorough guide Enabling Remote MySQL Access. I was able to get this to work by a simple setting in WHM called Additional MySQL Access Hosts. Visiting this area from Server B you would be able to add the IP address of Server A, allowing Server A to connect to Server B’s Database by using this format:
mysql_connect("IP Address of Server B","DB_username","DB_pass")
or whatever your preferred MySQL connection function is.
If this doesn’t work right away though, you may need to make some changes to firewall settings, but to my knowledge what you need should be possible.