1

I use some Virtual Hosts on Apache to speed up development. My configurations look like this:

<VirtualHost 127.0.0.1>
    ServerName my_server.dev
    DocumentRoot "my_root"

    <Directory "my_public_files">
        AllowOverride All
        Allow from All
    </Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
    ServerName another_server.dev
    DocumentRoot "another_root"

    <Directory "other_public_files">
        AllowOverride All
        Allow from All
    </Directory>
</VirtualHost>

and so on. I also add myserver.dev and another_server.dev to the hosts files, so putting one of those address into the browser takes me to my development environment.

For testing purposes. I would like to be able to access these Virtual Hosts from ohter machines on my LAN. I can access the main Host just by putting the server local IP, but I don't know how to access other Virtual Hosts.

I think I could do this by assigning a different port to each Host, but this becomes uncomfortable after a while. Any chance to access the Virtual Hosts by name on the LAN?

Andrea
  • 20,253
  • 23
  • 114
  • 183

2 Answers2

2

You have to modify the hosts file on all computers in your LAN, so that they know that another_server.dev should directed to your local server. Otherwise, dns lookup will be made and fail as the domain doesn't really exists.

c0mm0n
  • 969
  • 6
  • 6
0

You must access the server by name, not by IP. so, machines on you LAN should to know, where is the "another_server.dev", therefore you have to add into hosts-file line like:

10.0.0.1 another_server.dev my_server.dev

(replace 10.0.0.1 with your machine IP)

after this the machines on LAN can access your server with http://my_server.dev

clt60
  • 62,119
  • 17
  • 107
  • 194