通过局域网访问Apache虚拟主机 [英] Access Apache virtual host over lan

查看:345
本文介绍了通过局域网访问Apache虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的xampp配置为使用虚拟主机

在我拥有的apache/conf/extra/httpd-vhosts.conf上

NameVirtualHost *:80  //uncommented

<VirtualHost *:80>
DocumentRoot "Z:/xampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost web1.project>
DocumentRoot "Z:/xampp/htdocs/web1" 
ServerName web1.project

<Directory "Z:/xampp/htdocs/web1">
Options Indexes FollowSymLinks ExecCGI Includes
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

然后在我拥有的Windows/system32/drivers/etc/hosts上

127.0.0.1 localhost
127.0.0.1 web1.project

在我的机器上,它的运行正常,我可以直接在浏览器上访问 http://web1.project

但是在同一局域网的另一台机器上,不起作用,好吧,我知道了我的IP

我的网络图我的局域网上有每台机器的所有ips

运行xampp的计算机上有192.168.1.221

就像在平板电脑上一样,我可以进入192.168.1.221并运行xampp

如果我去192.168.1.221/web1可以正常工作

http://web1.project 不起作用

任何想法,要使它生效,我需要做什么?

谢谢.

解决方案

web1.project未在您的DNS中注册.

一种在另一台计算机上进行测试的快速而肮脏的方法,您可以在/etc/hosts中添加<IP ADDRESS> web1.project. 在Android设备上,您可以使用 https://play.google. com/store/apps/details?id = com.treb.hosts 修改android设备中的/etc/hosts文件(尽管我从未测试过)

i configured my xampp to use vhost

on apache/conf/extra/httpd-vhosts.conf i have

NameVirtualHost *:80  //uncommented

<VirtualHost *:80>
DocumentRoot "Z:/xampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost web1.project>
DocumentRoot "Z:/xampp/htdocs/web1" 
ServerName web1.project

<Directory "Z:/xampp/htdocs/web1">
Options Indexes FollowSymLinks ExecCGI Includes
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

then on windows/system32/drivers/etc/hosts i have

127.0.0.1 localhost
127.0.0.1 web1.project

on my machine its works perfect, i can go direct on browser and access http://web1.project

but on another machines on same lan, dont works, ok i figured my IP

my network map i have all ips for each machine on my lan

the computer here xampp is running have 192.168.1.221

so like on my tablet i can go 192.168.1.221 and i have xampp running

if i go 192.168.1.221/web1 works

but http://web1.project don't works

any idea, what i need to do to have put this to work?

thanks.

解决方案

web1.project is not registered in your DNS.

A quick and dirty way to test it on other computer , you can add <IP ADDRESS> web1.project in its /etc/hosts. On android device, you can use https://play.google.com/store/apps/details?id=com.treb.hosts to modify that /etc/hosts file in android device(though I have never tested it though)

这篇关于通过局域网访问Apache虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆