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

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

apache添加虚拟主机(windows下)

apache添加虚拟主机(windows下)

 

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

apache添加虚拟主机(windows下)

4.重启apache

相关文章:

  • 2022-01-23
  • 2021-12-25
  • 2022-01-25
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
猜你喜欢
  • 2022-12-23
  • 2021-12-30
  • 2021-12-11
  • 2022-01-01
  • 2022-12-23
  • 2022-01-06
相关资源
相似解决方案