2

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?

1 Answer 1

2

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.

3
  • 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
    Commented Dec 22, 2011 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
    Commented Dec 22, 2011 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
    Commented Dec 22, 2011 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .