Here is how to (always) get your server's a IP address. Works on Unix/Linux.

<?php
if (empty($_SERVER&#91;'SERVER_ADDR'&#93;)) {
$server_host = `hostname -f`;
$server_ip = `host $server_host`;

if (preg_match('#(d+.d+.d+.d+)#', $server_ip, $matches)) {
$server_ip = $matches&#91;1&#93;;
} else {
$server_ip = '127.0.0.1';
}
} else {
$server_ip = $_SERVER&#91;'SERVER_ADDR'&#93;;
}

echo $server_ip;
?>