apache2.4虚拟主机配置

apache2.4部分

conf/httpd.conf

1,Include conf/extra/httpd-vhosts.conf,去掉注释;

2,DocumentRoot "D:\apachespace",增加注释;

3,所有,增加注释;

4,*ServerName :80,增加注释;

conf/extra/httpd-vhosts.conf

1,所有 注释掉;

2,添加以下配置

         
                ServerAdmin [email protected]
                DocumentRoot "d:/www"
                ServerName test.cc
                DirectoryIndex index.html index.htm index.php
                ErrorLog "logs/test.cc-error.log"
                CustomLog "logs/test.cc-access.log" common
                # apache2.4下必须加目录权限的设置:
                
                        Options Indexes FollowSymLinks
                        AllowOverride All
                        Require all granted # 需注意,这段是apache2.4中的关键,与2.2不同
                

        
创建window服务,必须进入apapche的bin目录下执行httpd.exe -k install命令。
注: VirtualHost 是有顺序的,排在最前的是我们默认的网站域名。如果没有注释掉 httpd.conf 中的 DocumentRoot 和 ServerName,那么第一个虚拟主机的这两个配置都必须与 httpd.conf 中的一样,包括端口。所以建议注释掉 httpd.conf 中的标签

你可能感兴趣的:(web)