1、首先打开apache的配置文件httpd.conf,并去掉#Include conf/extra/httpd-vhosts.conf前面的#,启用虚拟主机功能

 # Virtual hosts
Include conf/extra/httpd-vhosts.conf
 Listen 127.0.0.1:80
Listen 80

2、先把localhost配置好,将下面信息添加到apache的apache/conf/extra下的配置文件httpd-vhosts.conf后面即可;

 <VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.hleclerc-PC.ingenidev
DocumentRoot "D:\wamp\www\tpshop\www.shop.com"
DirectoryIndex index.html index.php index.htm
ServerName wwww.shop.com
<Directory "D:\wamp\www\tpshop\www.shop.com">
AllowOverride All
Allow from All
</Directory>
</VirtualHost> <VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.hleclerc-PC.ingenidev
DocumentRoot "D:\wamp\www\tpshop\admin.shop.com"
DirectoryIndex index.html index.php index.htm
ServerName admin.shop.com
<Directory "D:\wamp\www\tpshop\admin.shop.com">
AllowOverride All
Allow from All
</Directory> </VirtualHost>

3、修改C:\Windows\System32\drivers\etc下的host文件,用记事本打开,添加

 127.0.0.1       admin.shop.com
127.0.0.1 www.shop.com

重启apache即可。

4、配置过程出现的问题

(1)Wamp Error: Could not execute menu item (internal error)

因为主要是修改过httpd.conf才出现的问题,所以将之前修改的配置文件还原,发现原来自己不小心把解释的内容给去注释了,结果导致httpd.conf运行不了

#//不加#会导致httpd.conf 出错
ServerAdmin: Your address, where problems with the server should be
e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. admin@your-domain.com
#
ServerAdmin admin@localhost

(2)访问www.shop.com和admin.shop.com总是访问到同一目录,原因是httpd-vhosts.conf在存在多处相同配置

 <VirtualHost 127.0.0.1:80>                   //使用 *:80 匹,否则ip  127.0.0.1 的站点都会使用D:/wamp/www的目录而不会向下查询
DocumentRoot "d:/wamp/www/"
ServerName localhost
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost> <VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.hleclerc-PC.ingenidev
DocumentRoot "D:\wamp\www\tpshop\www.shop.com"
DirectoryIndex index.html index.php index.htm
ServerName wwww.shop.com
<Directory "D:\wamp\www\tpshop\www.shop.com">
AllowOverride All
Allow from All
</Directory>
</VirtualHost> <VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.hleclerc-PC.ingenidev
DocumentRoot "D:\wamp\www\tpshop\admin.shop.com"
DirectoryIndex index.html index.php index.htm
ServerName admin.shop.com
<Directory "D:\wamp\www\tpshop\admin.shop.com">
AllowOverride All
Allow from All
</Directory> </VirtualHost>

Wamp环境下配置--Apache虚拟主机的更多相关文章

  1. windows环境下,apache虚拟主机配置

    在windows环境下,apache从配置文件的相关配置: Windows 是市场占有率最高的 PC 操作系统, 也是很多人的开发环境. 其 VirtualHost 配置方法与 Linux 上有些差异 ...

  2. wamp开发环境配置之配置Apache虚拟主机

    网站建设人员在本地测试时,常常不是一个网站,那怎么能像输入域名一样在地址栏上面输入“域名”就能本地访问该网站呢?这里就要配置Apache虚拟主机了! 1.找到apache\conf\httpd.con ...

  3. 配置LANMP环境(7)-- 配置nginx反向代理,与配置apache虚拟主机

    一.配置nginx反向代理 1.修改配置文件 vim /etc/nginx/nginx.conf 在35行http下添加一下内容: include /data/nginx/vhosts/*.conf; ...

  4. 配置Apache虚拟主机

    实验环境 一台最小化安装的CentOS 7.3虚拟机 配置基础环境 1. 安装apache yum install -y httpd 2. 建立虚拟主机的根目录 mkdir /var/wwwroot ...

  5. wamp环境下配置https证书后,网站内容访问受限

    wamp环境下配置https证书后,网站内容访问受限,点击首页链接标签后报错,大致意思是没有权限进行操作. 解决方法:打开apache的http.conf(位置大致如下:项目所在目录\bin\apac ...

  6. WAMP环境下配置虚拟主机

    1.编辑httpd.conf,查找#Include conf/extra/httpd-vhosts.conf,把前面注释符号“#”删掉 2.编辑httpd-vhosts.conf文件, <Vir ...

  7. 配置apache虚拟主机的实例总结

    如何实现apache虚拟主机配置. 1.基于ip地址的虚拟主机Listen 80<VirtualHost 172.20.30.40> DocumentRoot /home/httpd/ht ...

  8. mac下配置Apache虚拟域名方案,以及遇到的坑(转)

      1. 配置Apache虚拟域名 1.执行    sudo vi /etc/apache2/httpd.conf 开始配置httpd.conf 的文件; //配置listen 80端口(默认配置), ...

  9. mac下配置Apache虚拟域名方案,以及遇到的坑

      1. 配置Apache虚拟域名 1.执行    sudo vi /etc/apache2/httpd.conf 开始配置httpd.conf 的文件; //配置listen 80端口(默认配置), ...

随机推荐

  1. [Cocos2d-x开发问题-3] cocos2dx动画Animation介绍

    Cocos2d-x为了减少开发难度,对于动画的实现採用的帧动画的方案.这也就是说Cocos2d-x中的动画是帧动画. 帧动画的原理相信大家都不陌生,就是多张图片循环播放以实现动画的效果. 一个简单的动 ...

  2. ASP.NET - 使用 XML

    对XML文件进行简单的增加,删除,修改,查看等功能. XML代码: <?xml version="1.0" encoding="UTF-8"?> & ...

  3. Eclipse用法和技巧二:自动生成Main方法1

    刚开始编写java小程序,基本都要用到main方法.后期开发大一点的程序,也可以用main方法进行单元测试.总是编写main方法,感觉太无聊了,幸好Eclipse可以帮我们自动生成main方法.见图: ...

  4. Win2003 Server磁盘配额揭密之补遗篇

    Win2003 Server磁盘配额揭密之补遗篇 [ 作者:茶乡浪子    转贴自:it168.com    点击数:5011    更新时间:2005-1-17  ]   执行查看用户的磁盘配额信息 ...

  5. 基于visual Studio2013解决面试题之0708字符串全排列

     题目

  6. SRM 583 Div II Level Three:GameOnABoard,Dijkstra最短路径算法

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12556 用Dijkstra实现,之前用Floyd算法写了一个, ...

  7. 怎样基于谷歌地图的Server缓存公布Image Service服务

    怎样基于谷歌地图的Server缓存公布Image Service服务 第一步:下载地图数据 下载安装水经注万能地图下载器,启动时仅仅选择电子.谷歌(这里能够依据自己的须要选择).例如以下图所看到的. ...

  8. HDU1027 Ignatius and the Princess II 【next_permutation】【DFS】

    Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ( ...

  9. 【Cocos2d-X开发学习笔记】第28期:游戏中音乐和音效的使用

    本系列学习教程使用的是cocos2d-x-2.1.4(最新版为3.0alpha0-pre) ,PC开发环境Windows7,C++开发环境VS2010 UI在游戏中占有很重要的地位,但吸引玩家的除了这 ...

  10. 微信JSAPI支付(比较详细) 关于getRrandWCPayRequest:fail_invalid appid 错误

    原文:微信JSAPI支付(比较详细) 关于getRrandWCPayRequest:fail_invalid appid 错误 首先微信支付需注册  微信公从平台开发 和 微信支付商户平台 关于4个密 ...