wampserver2.0下配置虚拟主机

本文介绍了在WAMP环境下配置虚拟主机的两种方法。第一种方法通过修改httpd-vhosts.conf和httpd.conf文件实现;第二种方法则是在httpd-vhosts.conf中添加虚拟主机配置。最终确保了项目的正常访问。

第一种方法

1.项目位置

E:\wamp\www\dazhumsg

2.找到E:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf在文件最后写以下配置

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host2.localhost
    DocumentRoot "E:\wamp\www\dazhumsg"
    ServerName dazhumsg.cn
    DirectoryIndex index.php
    <Directory "e:/wamp/www/">
        Options FollowSymLinks
        AllowOverride all
        Order allow,deny
        Allow from all
        </Directory>
    ErrorLog "logs/dummy-host2.localhost-error.log"
    CustomLog "logs/dummy-host2.localhost-access.log" common
</VirtualHost>

3.重启apace服务。可悲的是在浏览器上打dazhumsg.cn不成功

4.找见httpd.conf打开

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

把Include conf/extra/httpd-vhosts.conf前面的#注释去掉

5.重启apace服务,更可悲的是在浏览器上打dazhumsg.cn还没成功。擦

6.直接把2中的代码写到了httpd.conf最底部

7.dazhumsg.cn成功。

 

第二种方法更好一点

1.重复第一种方法的第四步。

2.在httpd-vhosts.conf 添加

<VirtualHost *:80>
    ServerAdmin dazhu@jiade.com
    DocumentRoot "E:/wamp/www/wc"
    ServerName wanjc.com
</VirtualHost>

#Added this configuration for the WAMP www folder
<VirtualHost *:80>
    ServerAdmin dazhu@jiade.com
    DocumentRoot "e:\wamp\www"
    ServerName localhost
</VirtualHost>

3.重启服务。可以访问了

4.参考 :http://abou-kone.com/2011/04/25/wamp-apache-error-you-dont-have-permission-to-access-on-this-server/

error from Apache. A clue about going on to fix this came from commenting out the VirtualHost configuration line again in httpd.conf. That done, I was back in business with my www folder being visible again as well as all the projects within. It seemed that the VirtualHosts configurations were overriding the default Server configuration in httpd.conf. I then added the following code in httpd-vhosts.conf and both my C:\Dev\Workspace and C:\wamp\www folder were again “visible” and I was able to access projects in both locations:

最后 说一句,可能两种方法的项目名不一样。是因为写这篇随笔,是隔了两天左右了。是再次遇到这个问题后,采用第一种方法不好。才继续去寻找更好的方法。看不懂的见谅

转载于:https://www.cnblogs.com/fanglove/archive/2013/05/20/3089835.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值