apache添加虚拟主机(windows下)

 

 

1.打开Apache的目录下的  D:\Web\Apache\conf\httpd.conf

允许虚拟,启动虚拟配置文件

 

2.配置虚拟主机 打开 D:\Web\Apache\conf\extra\httpd-vhosts.conf

配置如下,如果需添加更多个,直接复制一份,修改DocumentRoot 和ServerName 还有 Dorectory,

#第一个虚拟主机,也就是覆盖Localhost的
<VirtualHost *:80>
#设置项目目录
    DocumentRoot "D:\Web\Apache\htdocs"
    #设置虚拟域名
    ServerName localhost
    #为shop主机设置访问权限
    <Directory "D:\Web\Apache\htdocs">
    #设置以列表形式显示文件
        Options Indexes
        #设置权限的顺序
        Order Deny,Allow
        #Deny from
        #允许所有用户访问
        Allow from All
        #让虚拟主机支持Rewrite重写
        AllowOverride ALL
        #设置apache默认访问页面
        DirectoryIndex index.php index.htm index.html
    </Directory>
</VirtualHost>

3.添加hosts

打开 C:\Windows\System32\drivers\etc\hosts

4.重启apache

posted @ 2017-06-15 18:40  Skrillex  阅读(247)  评论(0编辑  收藏  举报

power by Skrillex 2008