apache添加虚拟主机(windows下)

1.打开Apache的目录下的  D:WebApacheconfhttpd.conf

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

2.配置虚拟主机 打开 D:WebApacheconfextrahttpd-vhosts.conf

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

#第一个虚拟主机,也就是覆盖Localhost的
<VirtualHost *:80>
#设置项目目录
    DocumentRoot "D:WebApachehtdocs"
    #设置虚拟域名
    ServerName localhost
    #为shop主机设置访问权限
    <Directory "D:WebApachehtdocs">
    #设置以列表形式显示文件
        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:WindowsSystem32driversetchosts

4.重启apache

原文地址:https://www.cnblogs.com/Skrillex/p/7019439.html