apache 配置虚拟主机

1    打开httpd.conf

  找到

  # Virtual hosts

     #Include conf/extra/httpd-vhosts.conf  

  由于apache的版本不同,可能你ctrl+F 找不到 Virtual hosts,但是 Include conf/extra/httpd-vhosts.conf 是肯定有的,

    有可能是字母大小,也有可能是间距,致使ctrl+F 直接复制我的代码无法直接找到。一般是底部或者靠下的位置是肯定有的

  修改为(也就是把前面的#去掉)

  # Virtual hosts

     Include conf/extra/httpd-vhosts.conf    

2   打开conf/extra/httpd-vhosts.conf的这个文件

  <VirtualHost *:80>
  ServerName www.dacnnet.com
  DocumentRoot "../htdocs/phpcms"
  </VirtualHost>

  其中 ServerName 是你的虚拟主机名称  DocumentRoot 是地址,这个地址的路径要设置好,

  然后重启apache,重启apache并不是必须的,之所以这样做是apache可以检测出你这个配置是否正确,如果不正确apache是无法正常启动的。

  这样就避免了你不断刷新浏览器,却始终无法显示你想要的效果,也无法找到问题所在(我就遇到过)。

3  打开hosts 文件(C:\Windows\System32\drivers\etc)

  添加    127.0.0.1  www.dacnnet.com

  OK

posted on 2014-02-26 16:58  Hebe.大成  阅读(187)  评论(0编辑  收藏  举报

导航