在WAMP下设置本地访问的多个虚拟主机

一、在windows下本地域名解析设置: 

使用editPlus打开C:\WINDOWS\system32\drivers\etc\hosts文件进行编辑,如下:

# Copyright (c) 1993-1999 Microsoft Corp. 
# 
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows. 
# 
# This file contains the mappings of IP addresses to host names. Each 
# entry should be kept on an individual line. The IP address should 
# be placed in the first column followed by the corresponding host name. 
# The IP address and the host name should be separated by at least one 
# space. 
# 
# Additionally, comments (such as these) may be inserted on individual 
# lines or following the machine name denoted by a '#' symbol. 
# 
# For example: 
# 
# 102.54.94.97 rhino.acme.com # source server 
# 38.25.63.10 x.acme.com # x client host 
127.0.0.1 localhost 
127.0.0.1 www.example.com

二、进行Apache服务器解析设置: 

apache的配置文件在X:\php\Apache2\conf文件夹下,使用EditPlus打开httpd.conf文件进行编辑,如下:
NameVirtualHost *:80 
<VirtualHost *:80> 
    ServerAdmin localhost #可有可无  
    DocumentRoot d:\Network  #文件地址
    ServerName localhost  #写自己设定的虚拟域名或名称
#    ErrorLog logs/dummy-host.example.com-error_log 
#    CustomLog logs/dummy-host.example.com-access_log common 
<VirtualHost *:80> 
    ServerAdmin www.example.com #可有可无  
    DocumentRoot d:\Network 
    ServerName www.example.com  #写自己设定的虚拟域名或名称
#    ErrorLog logs/dummy-host.example.com-error_log 
#    CustomLog logs/dummy-host.example.com-access_log common 
</VirtualHost>

如果还要加虚拟地址,直接在上面一二步中的记录后面添加即可

如果hosts文件中有一条虚拟地址在httpd.conf文件中没有相对应的处理,貌似会被下一条虚拟地址覆盖,产生下一条虚拟地址的效果。

三、检查配置http.conf中

<Directory />
    Options FollowSymLinks
    AllowOverride all
    Order deny,allow
    allow from all
</Directory>

改为上述样式。

重启服务器。

或者将第三步直接添加入第二步中如下例子:

<VirtualHost *:80>
 ServerName localhost
 DocumentRoot "D:\WEB"
    <Directory "D:\WEB">
        Options FollowSymLinks IncludesNOEXEC Indexes
        DirectoryIndex index.html index.htm default.htm index.php default.php index.cgi default.cgi index.pl default.pl index.shtml
        AllowOverride All
        Allow from all
    </Directory>
</VirtualHost>


转载于:https://my.oschina.net/u/1258176/blog/265592

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值