码迷,mamicode.com
首页 > Windows程序 > 详细

Windows环境的apache下Virtual Host 设置

时间:2014-11-06 12:49:47      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   io   color   ar   os   使用   

  1、找到C:\Windows\System32\drivers\etc下的hosts文件,在文件最后增加以下内容:

127.0.0.1 mysite.net

  需要注意的是,此hosts文件可能会不让保存,解决的方法是将此hosts文件拷贝至其它位置(比如桌面),修改完毕后拷贝回来,将原文件覆盖即可。

  2、打开Apache的配置文件httpd.conf,找到Include conf/extra/httpd-vhosts.conf这行,如果这一句前面有#的话,将其去掉。

  3、打开Apache中conf\extra下的httpd-vhosts.conf文件,在最后写入:

 

  (1)PHP2.2下

NameVirtualHost *:80
<VirtualHost *:80>
ServerName mysite.net
DocumentRoot "D:\xampp\htdocs\mysite"
<Directory "D:\xampp\htdocs\mysite">
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm index.shtml default.html default.htm index.php default.php    
AllowOverride All    
Order Deny,Allow
Deny from All
Allow from 127.0.0.1    
</Directory> 
</VirtualHost>


  (2)PHP2.4下

<VirtualHost 127.0.0.1:80>
ServerName mysite.net
DocumentRoot "D:\xampp\htdocs\mysite"
<Directory "D:\xampp\htdocs\mysite">
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm index.shtml default.html default.htm index.php default.php
AllowOverride All
Require all denied
Require ip 127.0.0.1 ::1
Require local
</Directory>
</VirtualHost>
 
  4、重启Apache,浏览器中输入mysite.net就可以访问D:\xampp\htdocs\mysite这个项目了。

  注意:将上文中红色颜色部分的内容更换为你想要使用的虚拟域名,蓝色部分更换为对应项目存储的路径。
 

博客声明:

  本博客中的所有文章,除标题中注明“转载”字样外,其余所有文章均为本人原创或在查阅资料后总结完成,引用非转载文章时请注明此声明。—— 博客园-pallee

Windows环境的apache下Virtual Host 设置

标签:des   style   blog   http   io   color   ar   os   使用   

原文地址:http://www.cnblogs.com/pallee/p/4078349.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!