Question

How to separate MySQL Server from LAMP

Posted April 16, 2021 357 views
MySQLApachePHPLAMP Stack

i wanna have a server for php + apache2 and another server for MySQL.
i installed everything in each server but how can the 2 servers communicate what should i do to let my web app in the apache server communicate with the data base in the other server?
TY.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi there,

You will first need to allow remote connections for your MySQL server. You can do that by following the steps here:

https://www.digitalocean.com/community/tutorials/how-to-allow-remote-access-to-mysql

After that on your Apache/PHP server you would need to use your MySQL server IP for your database connection strings.

Let me know how it goes.
Regards,
Bobby

by Mark Drake
Many websites and applications start off with their web server and database backend hosted on the same machine. With time, though, a setup like this can become cumbersome and difficult to scale. A common solution is to separate these functions by setting up a remote database, allowing the server...
  • Thank you it Worked <3!

    but when I change the bindaddress to my (APACHE+php) IP server and I restart the MySQL server he refuses to restart and showed me an error. It worked just if I set the IP address to 0.0.0.0 and that’s not good for security I just want my (apache+php) server to connect to MySQL.

    *When i checked /var/log/mysql/error.log it say

    Can’t start server: Bind on TCP/IP port: Cannot assign requested address .