# Can Drupal have MySQL on a different server/jail?



## The-guy-using-BSD (Dec 10, 2014)

I'm using FreeBSD 10.1 and would like to know if I can host the databases on a different server/jail.

I want to build a website that sells products online.

My idea for the setup is to have three jails.

First jail: this jail contains www/apache24 and the www/drupal7 component
Second jail: this jail has the MySQL database for my products and prices.
Third jail: this jail contains the usernames and passwords and any balance they have at the store.

I would just like to know if this is possible and how would I do it if it is possible?


----------



## SirDice (Dec 10, 2014)

Never used Drupal but this shouldn't be a problem. Most of the time people use 127.0.0.1 but there's no reason why it would not work on any other IP address.


----------



## gkontos (Dec 10, 2014)

It is not only possible but also highly recommended for security reasons. I would use a different physical NIC for better segregation between the web and database.


----------



## The-guy-using-BSD (Dec 11, 2014)

I'm just having problems finding information on how I would do this. I'm new to Drupal and MySQL. I'm also new to jails but have read a few articles and with ezjail (I know currently it is using the old configuration method) it is going ok.


----------



## SirDice (Dec 12, 2014)

Configuring Drupal (or any other web based application) usually involves editing a config file and supplying a hostname or IP address of the database server, a database name and a username/password combination. Most examples will use 127.0.0.1 as the IP address which is the local machine. If you have a MySQL server on, for example, 192.168.12.21 you would use that IP address. Care must be taken when creating the database user, that one is usually "locked" to a certain IP address too. So you'll see accounts like drupal_user@127.0.0.1. The IP address in this case is the _source_ IP address from where the user connects. You would need to change that to the IP address of the webserver where Drupal is running. The % character is also used quite often but should not be used. It is a wildcard, a user account like drupal_user@% would be allowed to login from _any_ IP address. To improve security this shouldn't be used but may be a little easier to test with.


----------



## The-guy-using-BSD (Dec 12, 2014)

SirDice said:


> Configuring Drupal (or any other web based application) usually involves editing a config file and supplying a hostname or IP address of the database server, a database name and a username/password combination. Most examples will use 127.0.0.1 as the IP address which is the local machine. If you have a MySQL server on, for example, 192.168.12.21 you would use that IP address. Care must be taken when creating the database user, that one is usually "locked" to a certain IP address too. So you'll see accounts like drupal_user@127.0.0.1. The IP address in this case is the _source_ IP address from where the user connects. You would need to change that to the IP address of the webserver where Drupal is running. The % character is also used quite often but should not be used. It is a wildcard, a user account like drupal_user@% would be allowed to login from _any_ IP address. To improve security this shouldn't be used but may be a little easier to test with.


Thanks SirDice that information it is helpful. I have decided that I will set[]up everything in one jail. I have Drupal up and running and a little website. I now would like to know how I would access a different database for the products listed on the website. The second database needs product name, description, price, and stock level. Once I get all that set[]up and working I would like to copy the jail three times and edit the copies to give the results I mentioned at he beginning. Would that be a good idea?


----------

