I have a LAMP server - on there I have multiple domains. Each domain has its own user, db's, public_htmls/, etc.
I need to access Domain A's database from a web app on Domain B in php.
Currently I just use localhost
as my host for all DB connections in my web apps - but now I need to access a DB under a different domain so that obviously won't work.
Not sure if there is server (apache/php/dns) configuration required which would make this question better suited for server fault.
Any ideas?
If you only have one server, then localhost is still your local server. You only have one MySQL server for all your domains.
You simply need to specify a different database when you connect - you may still use localhost as the server.
According to my view the solution is very simple and for that you have to have the MySQL remote access and LAMP is managed by CPANEL and thus you or your service provider has to open the port for external connection. You can describe the specific ip address to connect only static ip address for security, static ip address would be your website ip address. After you open the port for connection then you can easily connect to the database of other domain whether it is on the same server or different server.