I have build a Drupal site on my local development server and I am preparing to move it to my test server and eventually my live server. I know where to find the database settings in my settings.php file, but there only appears to be one set of database configurations. I would like to know if there is a good way to include three different database settings in my settings.php file, one for my development environment, one for my test server and one for my live server. I could simply add a settings section to the file for each and simply comment out the ones that I am not using, but I would like to use an automatic solution, one that can either allow me to specify a setting for all three locations, or tries each setting until it finds a setting that works.


Berdir wrote about a very nice solution some time ago, which also made it into Drupal 8 now.

It means that you keep separate settings.php's, which are included whenever available with a small code snippet.

| improve this answer | |
  • Looks good. It first I considered this to be 'hacking core' but it's not because the file exists in the sites folder. Also, Drupal.org does it, so it must be a good solution. – Hoytman Apr 8 '14 at 20:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.