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

I am running Apache 2.2 on XP. I want to set up Apache so that I have different test sites (each listening on a different port), to be accessed by other machines on my internal (home network).

I have managed to setup different virtual hosts (all using port 80), I have then used the host file to provide server names like:

127.0.0.1 localhost 127.0.0.1 test.php.localhost 127.0.0.1 phpmyadmin.localhost

etc

This works fine on my local machine, in that I can acces http://phpmyadmin.localhost/ (for example, on my local machine. However, when I go to another machine I cannot type http://phpmyadmin.localhost/ I can only type http://[server.ip.address] which in this case, gives me the first website listed in my httpd.conf file.

I have two (possibly related) questions

  1. What do I need to do so that I can access http://phpmyadmin.localhost/ from another machine in the LAN (is it simply a case of modifying the host file on each machine, or is it more complicated?)
  2. How do I access a SPECIFIC website (on my local server), from one of the machines in my network, instead of being automatically assigned to the first wite listed in httpd.conf?
share|improve this question

1 Answer 1

What do I need to do so that I can access http://phpmyadmin.localhost/ from another machine in the LAN (is it simply a case of modifying the host file on each machine, or is it more complicated?)

localhost has its own entry in each computer's hosts file - it points to the special loopback IP address 127.0.0.1, or the local machine. Any given machine look for locally (on itself) when any request is made to 127.0.0.1 by the browser, and as you've pointed all your hosts entries to 127.0.0.1 you cannot copy this configuration onto other machines, you must use the public facing IP of your host machine.

You should either host DNS records on the local network, or far more simply alter each client machine's hosts file at C:\WINDOWS\system32\drivers\etc\hosts

192.168.1.72    phpmyadmin phpmyadmin.mymachine testing.somemachine

This will make all requests to http://phpmyadmin/ direct to IP address 192.168.1.72

How do I access a SPECIFIC website (on my local server), from one of the machines in my network, instead of being automatically assigned to the first wite listed in httpd.conf?

Ensure you have configured your hosts file - if you are using name based virtual hosting you'll need to hit the server with the relevant server name (i.e. phpmyadmin above) so the server can search for that server/alias in the vhost configuration and load the appropriate data.

share|improve this answer
    
I have exactly this setup, but they don't work. When I ping them from client like ping dev.example.net, it does show that its picking up the local IP from the hosts file but it doesn't get any replies from the server(desktop machine hosting the localhost). What would you suggest to troubleshoot? I am using Ubuntu 11.10 on both machines. –  Ashfame Dec 22 '11 at 14:11
    
To add, ping desktopIP works, so I don't think its a firewall issue. Apache on desktop doesn't respond, what else could be missing? –  Ashfame Dec 22 '11 at 14:23
    
iptables is always fun on Linux hosts, but you'll get a better response by asking a new question so others can contribute. –  Andy Dec 22 '11 at 16:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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