同一ip配置多个虚拟地址

1. apache\conf\httpd.conf 中vhosts包含#去掉,如下:

# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"

2.修改C:\Windows\System32\drivers\etc\hosts,添加虚拟地址与ip映射

192.168.1.71 myself.newdev.zhiwo.com
192.168.1.71 www.test.com

3.修改 apache\conf\extra\httpd-vhosts.conf 如下:

NameVirtualHost *:80  --前面的两个##号去掉

#myself.newdev.zhiwo.com对应的配置

<VirtualHost *:80>
ServerAdmin postmaster@dummy-host.localhost
DocumentRoot "D:/xampplite/htdocs/dapperPHP/webroot/"
ServerName 192.168.1.71:80
ServerAlias myself.newdev.zhiwo.com
ErrorLog "logs/dummy-host.localhost-error.log"
CustomLog "logs/dummy-host.localhost-access.log" combined
Alias /static/ "D:/xampplite/htdocs/dapperPHP/View/"
<Directory "D:/xampplite/htdocs/dapperPHP/webroot/">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>

#www.test.com对应的配置
<VirtualHost *:80>
ServerAdmin postmaster@dummy-host2.localhost
DocumentRoot "D:/xampplite/htdocs/test/"
ServerName 192.168.1.71:80
ServerAlias www.test.com
ErrorLog "logs/dummy-host2.localhost-error.log"
CustomLog "logs/dummy-host2.localhost-access.log" combined
<Directory "D:/xampplite/htdocs/test/">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>

4.重启apache和浏览器,分别输入myself.newdev.zhiwo.com,www.test.com就会打开其相对应的网页

转载于:https://www.cnblogs.com/snowflakewant/p/3631267.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值