在httpd.conf的目录下,新建一个配置文件virtualhost-host.conf,添加虚拟主机配置
<VirtualHost *:80>
DocumentRoot "E:liuxgliuxg1"
ServerName www.liuxg1.com
<Directory "E:liuxgliuxg1">
Options Indexes FollowSymLinks <!-- 若目录下有index则自动打开index文件,如果没有则列出文件列表 -->
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:liuxgliuxg2"
ServerName www.liuxg2.com
<Directory "E:liuxgliuxg2">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
将virtualhost-host.conf导入到httpd.conf里面
include confvirtualhost-host.conf
最后在host文件添加域名影射
127.0.0.1 www.liuxg1.com
127.0.0.1 www.liuxg2.com