Forum Moderators: coopster

Message Too Old, No Replies

phpinfo()

IP address of server

         

yellow_nemo

6:22 pm on Feb 2, 2006 (gmt 0)

10+ Year Member



Hi, I need to find out the IP address of my web server, which I believe is under a name-based virtual host. I used phpinfo() to check what the IP address is, but then I thought since my website is stored in a name-based virtual host, which a couple of host names can have the same IP address. So that wouldn't be the correct way to go for, right? Is there a way I can find out the correct IP address or I would have to ask the adminstrator? Thanks.

StupidScript

6:37 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try pinging your domain name.

Open a command prompt window and type

ping example.com
using your domain name. As the program executes, it will resolve the IP address and display it for you.

Regardless of whether you are in a virtual hosting situation or not, you will see the IP address being used for your domain resolution.

inbound

6:42 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



phpinfo will return the IP of the server that the script has run on.

In a shared environment it is very unlikely that your site will be on more than one IP so the one reported by phpinfo should be reliable.

yellow_nemo

7:44 pm on Feb 2, 2006 (gmt 0)

10+ Year Member



inbound, I work on two websites with different domain names under the same virtual host. I checked both of their phpinfo() and both of them give me the same _SERVER["REMOTE_ADDR"] and _SERVER["SERVER_ADDR"].
Does that mean they are indeed sharing the same IP?

StupidScript, I pinged my domain name and the IP I got does come up to be different than the ones phpinfo listed. Does that mean that should be the correct IP?

StupidScript

9:00 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The address listed by phpinfo() is the 'internal' address of the machine ... actually, the 'real' address the NIC is assigned to.

The address listed by ping is the 'external' address of the site, and is provided by domain name resolution at the DNS level.

So, they are both correct. One as seen from the inside, and one as seen from the outside.

You can expect both of your domains to return the same info using either method, as the assignments that create your 'virtual domains' are being done in the server software configuration. i.e. in Apache's httpd.conf.