Answers.Body: <p>The short answer is yes — you need to use a domain names.</p>
  
  <p>You might also want to have a look at this <a href="http://craftcookbook.net/recipes/273" rel="nofollow noreferrer">multi-environment configuration method</a> defined on the craft cookbook website that creates a global php variable called CRAFT_ENVIRONMENT in your main index.php.</p>
  
  <p>I generally use that in combination with Ben Parizek technique as described in <a href="https://craftcms.stackexchange.com/a/4734/784">this answer</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-14T15:12:03.853Z
Answers.Text: Why bummer? Do you not have a domain name? I should clarify that if you are accessing the server via the IP address in the browser, then the ip address should also work as the domain name. And if you really want to use the IP address regardless, then I'm sure you could also set the CRAFT_ENVIRONMENT variable based on the ip address using `SERVER('SERVER_ADDR')`. For localhost, you would just also need to use 127.0.0.1.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-15T16:29:22.160Z
Answers.Text: I'm working on a site for a client, they have a domain name, but I don't want to switch this site live yet, so I have set up server space elsewhere and have them access the site via the IP address. Once finshed, I will switch the DNS records to this server. Will have to look more into CRAFT_ENVIRONMENT variable, I am not that familiar with using it.
Answers.UserDisplayName: Nick
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-15T16:51:24.213Z
Answers.Text: I see your problem. To clarify the 'CRAFT_ENVIRONMENT' variable is a made-up variable used in the craft cookbook configuration method that I linked. But you'll notice with that they are using server variables to determine the environment — don't see why you couldn't use the IP instead of domain name to do the same thing. Another option that might work is to create a subdomain (stage.domain.com) and only point the subdomain to that server.
Answers.UserDisplayName: Douglas McDonald
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-13T15:09:07.103Z
Answers.LastActivityDate: 2015-04-13T15:30:12.037Z
Answers.LastEditDate: 2017-04-13T12:50:59.930Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I'm trying to set up multi-environment configs.</p>
  
  <p>I have specific db settings I want to change depending on environment. I am using <code>localhost</code> and my Digital Ocean server IP address in my db.php file.</p>
  
  <pre><code>&lt;?php
  
  return array(
  
  '*' =&gt; array(
      'tablePrefix' =&gt; 'craft',
  ),
  'localhost' =&gt; array(
          'server' =&gt; 'localhost',
          'user' =&gt; 'root',
          'password' =&gt; 'root',
          'database' =&gt; 'something',
  ),
  'xxx.xxx.xxx.xxx' =&gt; array(
              'server' =&gt; 'localhost',
              'user' =&gt; 'some_user',
              'password' =&gt; 'some_password',
              'database' =&gt; 'somethingelse',
      ),
  );
  </code></pre>
  
  <p>I've tried switching the order, that did not work.</p>
  
  <p>Do I need to use a domain name rather than a IP address here?</p>
  
Tags: <config><multi-environment><multi-domain>
Title: Using an IP address in config/db.php
ThreadText: # Using an IP address in config/db.php
  
  (Asked by: username_0 on 2015-04-13)
  
  I'm trying to set up multi-environment configs.
  
  I have specific db settings I want to change depending on environment. I am using `localhost` and my Digital Ocean server IP address in my db.php file.
  
  ```
  <?php
  
  return array(
  
  '*' => array(
      'tablePrefix' => 'craft',
  ),
  'localhost' => array(
          'server' => 'localhost',
          'user' => 'root',
          'password' => 'root',
          'database' => 'something',
  ),
  'xxx.xxx.xxx.xxx' => array(
              'server' => 'localhost',
              'user' => 'some_user',
              'password' => 'some_password',
              'database' => 'somethingelse',
      ),
  );
  
  ```
  
  I've tried switching the order, that did not work.
  
  Do I need to use a domain name rather than a IP address here?
  
  **Tags:** config, multi-environment, multi-domain
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-04-13. Score: 4 | Accepted answer
  
  The short answer is yes — you need to use a domain names.
  
  You might also want to have a look at this [multi-environment configuration method](http://craftcookbook.net/recipes/273) defined on the craft cookbook website that creates a global php variable called CRAFT\_ENVIRONMENT in your main index.php.
  
  I generally use that in combination with Ben Parizek technique as described in [this answer](https://craftcms.stackexchange.com/a/4734/784).
  
  > **Comments:**
  > **username_1**: Why bummer? Do you not have a domain name? I should clarify that if you are accessing the server via the IP address in the browser, then the ip address should also work as the domain name. And if you really want to use the IP address regardless, then I'm sure you could also set the CRAFT_ENVIRONMENT variable based on the ip address using `SERVER('SERVER_ADDR')`. For localhost, you would just also need to use 127.0.0.1.  
  > **username_0**: I'm working on a site for a client, they have a domain name, but I don't want to switch this site live yet, so I have set up server space elsewhere and have them access the site via the IP address. Once finshed, I will switch the DNS records to this server. Will have to look more into CRAFT_ENVIRONMENT variable, I am not that familiar with using it.  
  > **username_1**: I see your problem. To clarify the 'CRAFT_ENVIRONMENT' variable is a made-up variable used in the craft cookbook configuration method that I linked. But you'll notice with that they are using server variables to determine the environment — don't see why you couldn't use the IP instead of domain name to do the same thing. Another option that might work is to create a subdomain (stage.domain.com) and only point the subdomain to that server.  
  
  ---
  
  