Windows 配置Apache 基于域名的虚拟主机

打开目录 {Apache2 安装目录}\conf\extra\,找到 httpd-vhosts.conf 文件

在下面添加如下代码:

<VirtualHost *:80>
    ServerAdmin webmaster@123admin.com
    DocumentRoot "E:/wwwroot/123admin.com"
    ServerName www.123admin.com
    ServerAlias 123admin.com
    ErrorLog logs/123admin.com-error_log
    CustomLog logs/123admin.com-access_log combined
    DirectoryIndex index.html index.htm index.php
   <Directory E:/wwwroot/123admin.com>
        Options -Indexes ExecCGI FollowSymLinks
        Order allow,deny
        Allow from all
        AllowOverride all
    </Directory>
</VirtualHost>

打开 httpd.conf 文件, 添加如下语句

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

重启 Apache 服务