更改Apache虚拟主机流程

1.在httpd.conf文件中启用httpd-vhosts.conf

  去掉#,即

#Virtual hosts (虚拟主机)
Include conf/extra/httpd-vhosts.conf

2.假设虚拟主机在 D:/www 目录下 (需事先建立站点)

3.设置http-vhosts.conf文件(路径:X:/ApacheX.X/conf/extra/http-vhosts.conf)

  添加以下内容:

#配置虚拟主机
<VirtualHost 127.0.0.1:80>
    DocumentRoot "d:/www/web"
    #配置欢迎首页面
    DirectoryIndex index.html index.htm index.php
    <Directory />
    Options FollowSymLinks
    #不许别人修改网站页面
    AllowOverride None
    #设置访问权限
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

4.在hosts文件中添加我们的ip和主机映射关系(路径:c:/windows/system32/drivers/etc/hosts)

  在 127.0.0.1  localhost下添加如下地址

127.0.0.1    www.XXX.com

配置完成!

 这样就能通过www.XXX.com来访问我们自己的网站了。。

posted @ 2014-08-10 12:28  ayee  阅读(189)  评论(0编辑  收藏  举报