Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a web server (xampp) in a particular PC running on my LAN, and I added the following line in the 'hosts' file : 127.0.0.1 mysite.

Then, in another PC connected to the LAN, I'm trying to acces the previous web server by typing 'http://mysite/index.php' on the web browser, with no luck. But if I type the IP from the server computer (http://192.168.2.87/index.php) I am able to access the web site.

So, what should i configure so when i type 'http://mysite/index.php' I get the same result as http:// 192.168.2.87/index.php ??

Thanx!

share|improve this question

closed as off topic by Brent Pabst, HopelessN00b, Tim Brigham, Stefan Lasiewski, Oskar Duveborn Sep 5 '12 at 21:13

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
The hosts files is only for DNS look-ups made by the local machine it's self that that hosts file reside on. So adding an entry to hosts on one machine is useless when trying to reference that name mysite from another machine. –  jwbensley Sep 5 '12 at 20:43
    
Is this a duplicate question? It seems like there should already be a canonical answer which explains the purpose of /etc/hosts and the meaning of 127.0.0.1 . I cannot find such a question. –  Stefan Lasiewski Sep 5 '12 at 20:45
add comment

2 Answers

You should modify the hosts file of the other computer (the one that's not running the web server). It should contain a line like this one:

192.168.2.87 mysite
share|improve this answer
add comment

The reason this happens is that the host file only affects the computer it's on. You'll need to modify the host file of every computer on your network if you wish to access the site from those computers using this method.

You'll also want to reference the web server by the machine's actual IP (192.168.2.87) when editing the host files of the other computers on your network. 127.0.0.1 is a loopback that references your current machine.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.