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. java class生成jar包(转)

    进入dos操作符窗口cd进入要打成jar包的class文件所有文件夹目录jar cvf [生成jar的名称.jar] [列出class文件] //若有多个,以空隔隔开 如:一.操作零散的单个或几个cl ...

  2. nexus搭建

    Nexus是Maven仓库管理软件,可以用来搭建私服.主页 http://www.sonatype.org/nexus/ 下载地址 http://www.sonatype.org/nexus/down ...

  3. 基于visual Studio2013解决面试题之1204大数组查找

     题目

  4. C语言指针和数组知识总结(上)

    C语言指针和数组知识总结(上) 一.指针的基础 1.C语言中,变量的值能够通过指针来改变,打印指针的语句符号可以是:  %08x 2.指针的本质 指针的本质就是变量,那么既然是变量,那么一定会分配地址 ...

  5. android 按字母搜索

    在看Oplayer的时候看见滑动字母来实现listView的内容搜索,所以就把里面的核心的函数扣除来做了一个demo,分为两部分一个是布局,另一个就是代码了,具体的如下: 布局: <?xml v ...

  6. Linux路由器

    Linux路由器 武溪嵌人 钻研嵌入式,改变未来 http://blog.csdn.net/zhang_danf     Linux路由器 http://blog.csdn.net/zhang_dan ...

  7. 24篇HTTP博客

    http://www.cppblog.com/woaidongmao/category/11721.html

  8. actor简介

    今天抽时间,给team做了一次actor介绍,现附上ppt actor 简介及应用

  9. [置顶] android关机闹钟设计思路

    1: 首先需要硬件支持,支持alarm中断触发开机,目前高通平台几乎都支持: 2:关机前需要在rtc-xxx.c中做到enable_irq_wake,和不disable alarm功能(默认开机后al ...

  10. js计算日期相差的天数

    在网站开发中,经常会遇到计算日期相差的天数,js 没有提供相应的方法,所以自己写一个,方便将来查看: 代码: function DateDiff(sDate1, sDate2, splitStr) { ...