本文介绍了阿帕奇:请参阅从LAN名为虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Apache的一些虚拟主机,加快发展。我的配置是这样的:

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>

和等。我也 myserver.dev another_server.dev 添加到主机文件,所以把这些地址之一到浏览器带我到我的开发环境。

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.

有关测试目的。我希望能够从ohter机器访问我的局域网上这些虚拟主机。我可以通过将服务器的本地IP访问的主​​要宿主,但我不知道如何访问其他的虚拟主机。

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?

推荐答案

您必须按名称访问服务器,而不是IP。
所以,你的机器应该LAN要知道,这里是another_server.dev,因此,你必须添加到像主机文件行:

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

(替换用10.0.0.1你的机器IP)

(replace 10.0.0.1 with your machine IP)

在此之后对局域网的机器可以用

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

这篇关于阿帕奇:请参阅从LAN名为虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 17:36