Access Apache virtual host over lan

2019-08-02 02:51发布

问题:

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.

回答1:

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)