title: Simply find the ip address of server
body: <p>The following code to find the actual local ip address (e.g. <code>192.168.1.X</code>) of the host server has run fine on a dev machine</p>
  
  <pre><code>$ip = getHostByName( getHostName() );
  </code></pre>
  
  <p>Transferring it to another server it started to output <code>127.0.0.1</code></p>
  
  <p>It seems that getHostName() returns <code>localhost</code> which in turn gets converted to <code>127.0.0.1</code> by getHostByName().</p>
  
  <p>Looking at other questions here it seemed that <code>$_SERVER['SERVER_ADDR']</code> might solve the puzzle but this is also returning <code>127.0.0.1</code></p>
  
  <p>Checking and searching the output from <code>phpinfo()</code> returns no clues to the actual ip address of the machine.</p>
  
  <p>Seriously, does anyone know a bullet proof (simpler the better) way of getting the ip address of the machine running the script? Why is it so hard to get such fundamental data without doing back flips?</p>
  
  <p>I really don't want to be hardcoding the ip address in a config file...</p>