[置顶] apche2.4 基于前缀域名的虚拟主机配置

首先说明,基于前缀的域名和基于域名的虚拟主机是一个概念,所以和基于域名的虚拟的主机没什么两样

第一步  

打开apache下httpd.conf文件

启用模块LoadModule vhost_alias_module modules/mod_vhost_alias.so

NameVirtualHost 这个参数在Apache2.4 这个版本已经被去除了。。


<VirtualHost *:80>
    ServerAdmin [email protected]
DocumentRoot "D:\PHP\www\advanced\api\web"
    ServerName api.red.com
    ServerAlias api.red.com
    ErrorLog "logs/api.red.com.log"
    CustomLog "logs/api.red.com.CustomLog.log" common

   <Directory "D:\PHP\www\advanced\api\web">
        Require all granted
   </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin [email protected]
DocumentRoot "D:\PHP\www\advanced\frontend\web"
    ServerName frontend.red.com
    ServerAlias frontend.red.com
    ErrorLog "logs/frontend.red.com.log"
    CustomLog "logs/frontend.red.com.CustomLog.log" common

   <Directory "D:\PHP\www\advanced\frontend\web">
        Require all granted
   </Directory>
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin [email protected]
DocumentRoot "D:\PHP\www\advanced\backend\web"
    ServerName backend.red.com
    ServerAlias backend.red.com
    ErrorLog "logs/backend.red.com.log"
    CustomLog "logs/backend.red.com.CustomLog.log" common

   <Directory "D:\PHP\www\advanced\backend\web">
        Require all granted
   </Directory>
</VirtualHost>


你可能感兴趣的:(域名,虚拟主机)