从 LAN 上的任何计算机访问 Apache VirtualHost?
我有 wamp 设置,其中有很多网站设置为 httpd.conf 中的虚拟主机,
<VirtualHost 127.0.0.1>
ServerName project1.local
DocumentRoot "c:/wamp/project1/"
</VirtualHost>
我在 wamp 机器的主机文件中输入了这些内容,我可以在该机器上很好地访问它们。
127.0.0.1 project1.local
然而,当我尝试在我的 OSX 机器上输入一个条目(192.168.1.101 是 wamp 机器的内部 IP)时,它不会拉出页面。
192.168.1.101 project1.local
我还需要做些什么才能在其他机器上完成这项工作吗?谢谢!
I have wamp setup with quite a few websites setup as virtual hosts like this in httpd.conf
<VirtualHost 127.0.0.1>
ServerName project1.local
DocumentRoot "c:/wamp/project1/"
</VirtualHost>
I have these input in the wamp machine's host file and I can access them just fine on that machine.
127.0.0.1 project1.local
However, when I try to put an entry on my OSX machine as (192.168.1.101 being the internal ip of the wamp machine) it won't pull the page up.
192.168.1.101 project1.local
Is there something else I need to do to make this work from other machines? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要
(除了 127.0.0.1 之外),或者只需使用
将 VH 放在所有地址上。You either need
<VirtualHost 192.168.1.101>
(in addition to 127.0.0.1), or simply use<VirtualHost *>
to put the VH on all addresses.只需在虚拟主机配置文件中添加以下代码
在下面的代码中,
'Client_IP' 是您要访问目录的计算机的 IP,无需在地址栏上使用任何 ip,只需将服务器名称放在地址栏中,例如 'servername/'。
设置与 apache 服务器上的虚拟主机相同的服务器名称,
。
然后,在客户端计算机 c:/windows/system32/drivers/etc/hosts 文件中
Just add below code in your virtual host config file
In the below code,
'Client_IP' is the IP of the machine from where you want to access the directory without using any ip on the address bar, just put severname in the address bar like 'servername/'.
Then, set same servername that you have used for the virtual host on apache server like,
in the client machine c:/windows/system32/drivers/etc/hosts file.