开发者

Apache: see named virtual hosts from LAN

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"

    &l开发者_如何学Got;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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜