关于Apache配置虚拟主机后在局域网中让其他电脑访问
1 #-----------adxssp------------# 2 NameVirtualHost *:80 3 <VirtualHost *:80> 4 ServerName www.b.com 5 DocumentRoot "/Users/renxing/www/adxssp/src/www" 6 </VirtualHost> 7 8 <Directory "/Users/renxing/www/adxssp/src/www" > 9 Options Indexes FollowSymLinks 10 AllowOverride All 11 Order allow,deny 12 Allow from all 13 </Directory> 14 15 #-----------test------------# 16 NameVirtualHost *:80 17 <VirtualHost *:80> 18 ServerName www.t.com 19 DocumentRoot "/Users/renxing/www/test" 20 </VirtualHost> 21 22 <Directory "/Users/renxing/www/test" > 23 Options Indexes FollowSymLinks 24 AllowOverride All 25 Order allow,deny 26 Allow from all 27 </Directory> 28 29 #-----------admin------------# 30 NameVirtualHost *:80 31 <VirtualHost *:80> 32 ServerName www.a.com 33 DocumentRoot "/Users/renxing/www/admin/src/www" 34 </VirtualHost> 35 36 <Directory "/Users/renxing/www/admin/src/www" > 37 Options Indexes FollowSymLinks 38 AllowOverride All 39 Order allow,deny 40 Allow from all 41 </Directory> 42 43 44 45 #-----------developer------------# 46 NameVirtualHost *:80 47 <VirtualHost *:80> 48 ServerName www.c.com 49 DocumentRoot "/Users/renxing/www/developer/src/www" 50 </VirtualHost> 51 52 <Directory "/Users/renxing/www/developer/src/www" > 53 Options Indexes FollowSymLinks 54 AllowOverride All 55 Order allow,deny 56 Allow from all 57 </Directory> 58 59 60 61 62 #------------ 错误显示 -----------# 63 php_flag display_errors on 64 php_value error_reporting 2039
如上所示,共配置了4个虚拟主机:
www.a.com
www.b.com
www.c.com
www.t.com
如果我本机 的IP地址是:192.168.1.123
那么在 局域网内访问此IP看到的网站就是上面配置中第一个配置的虚拟主机,本案例中就是:www.b.com
如果想要访问别的虚拟主机,那么只需要把对应的主机放置到最前面即可!