Personally, I don't commit settings.php in version control (settings.default.php is), and then just save my own settings.php file based on settings.default.php in each environment.
However, if you prefer to set up your environment this way, then something like this will work in your sites / default / settings.php file.
define('DEVELOPMENT', 'mysite.local'); define('PRODUCTION', 'mysite.com'); switch ($_SERVER['SERVER_NAME']) { case DEVELOPMENT: // development server $db_url = 'mysql://user: pass@localhost /mydb_dev'; $db_prefix = ''; $base_url = 'http://mysite.local'; $conf = array( 'site_name' => 'Development Environment', ); break; default: // live server $db_url = 'mysql://user: pass@localhost /mydb_prod'; $db_prefix = ''; $base_url = 'http://mysite.com'; $conf = array( 'site_name' => 'My Site', ); break; }
Remember that for each of these vars that you use here, you need to comment on whether they are defined in other parts of settings.php.
I should also add that I believe that a multi-site site with the goal of creating an environment is a bad idea, for the same reason I prefer that each environment has its own settings.php file. In most cases, I prefer to keep portable code in that I donβt need links to any code or file system for any environment, except in the settings file for the environment in which I run the code.
Using Drupal's multisite functionality for each environment that needs to be developed and implemented, as others suggest, will be insane to manage.
source share