Multi-Environment Config Database Credentials Being driven to distraction trying to setup multiple environments with Craft. I have Craft running (and working) locally without issue. I have created a staging server with Digital Ocean and setup the appropriate database. I'm using DeployBot to push changes from Github.

However upon trying to access the remote server, I get the following errors:


  Service Unavailable
  
  Our site is temporarily unavailable. Please try again later.


and 


  Craft can’t connect to the database with the credentials in
  craft/config/db.php.


I'm sure there is an obvious solution to why this isn't working, but I'm yet to find it.

Here are my db.php and general.php files with sensitive data redacted:

db.php
    

return array(
  '*' =&gt; array(
    'database' =&gt; '******',
    'tablePrefix' =&gt; 'craft',
  ),

  'localhost' =&gt; array(
    'server' =&gt; 'localhost',
    'user' =&gt; 'root',
    'password' =&gt; 'root',
  ),

  // Use IP of your droplet and MySQL credentials of a user you created
  '000.000.000.000' =&gt; array(
    'server' =&gt; '000.000.000.000',
    'user' =&gt; 'root',
    'password' =&gt; '***********',
  )
);


config.php

&lt;?php

return array(
    '*' =&gt; array(
        'omitScriptNameInUrls' =&gt; true,
        'devMode' =&gt; true,
        'loginPath' =&gt; 'users/login',
        'postLoginRedirect' =&gt; 'commerce/customer',
        'setPasswordPath' =&gt; 'users/setpassword',
        'enableCsrfProtection' =&gt; true,
    ),

    '000.000.000.000' =&gt; array(
      'siteUrl' =&gt; 'http://000.000.000.000/',
      'environmentVariables' =&gt; array(
        'basePath' =&gt; '/var/www/html/',
        'baseUrl' =&gt; 'http://000.000.000.000/',
      )
    ),

);


Also index.php file for good measure

&lt;?php

// Path to your craft/ folder
$craftPath = '../craft';

// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';

if (!is_file($path))
{
    if (function_exists('http_response_code'))
    {
        http_response_code(503);
    }

    exit('Could not find your craft/ folder. Please ensure that &lt;strong&gt;&lt;code&gt;$craftPath&lt;/code&gt;&lt;/strong&gt; is set correctly in '.__FILE__);
}

require_once $path;


Help needed and much appreciated!
Here is what my configuration looks like. Ideally, I'd like to swap out the hard-coded baseUrl with something like I have for basePath. That way the other members on my team can call/put the site wherever they want and it won't break anything.

I don't make any changes to index.php.

Hope this helps!

db.php

return array(
'*' =&gt; array(
    'tablePrefix' =&gt; ''
),
'.dev' =&gt; array(
    'server' =&gt; 'localhost',
    'user' =&gt; 'username',
    'password' =&gt; 'password',
    'database' =&gt; 'dbname'
),
'mysite.stagingdomain.com' =&gt; array(
    'server' =&gt; '12.345.67.890',
    'user' =&gt; 'username',
    'password' =&gt; 'password',
    'database' =&gt; 'dbname'
),
'mysite.com' =&gt; array(
    'server' =&gt; '12.345.67.890',
    'user' =&gt; 'username',
    'password' =&gt; 'password',
    'database' =&gt; 'dbname'
)


);

general.php

return array(
    '*' =&gt; array(
    'cpTrigger' =&gt; 'admin',  // whatever you want
    'omitScriptNameInUrls' =&gt; true,
    'enableCsrfProtection' =&gt; true
),
'.dev' =&gt; array(
    'devMode' =&gt; true,
    'siteUrl' =&gt; 'http://mysite.dev/',
    'environmentVariables' =&gt; array(
        'basePath' =&gt; $_SERVER['DOCUMENT_ROOT'] . '/',
        'baseUrl' =&gt; 'http://mysite.dev/', 
    )
),
'mysite.stagingdomain.com' =&gt; array(
    'devMode' =&gt; true,
    'siteUrl' =&gt; 'http://mysite.stagingdomain.com/',
    'environmentVariables' =&gt; array(
        'basePath' =&gt; $_SERVER['DOCUMENT_ROOT'] . '/',
        'baseUrl' =&gt; 'http://mysite.stagingdomain.com/'
    )
),
'mysite.com' =&gt; array(
    'siteUrl' =&gt; 'http://www.mysite.com/',
    'environmentVariables' =&gt; array(
        'basePath' =&gt; $_SERVER['DOCUMENT_ROOT'] . '/',
        'baseUrl' =&gt; 'http://www.mysite.com/'
        )
    )
);