windows下Apache配置多个站点
1. httpd.conf 找到以下两行去掉注释:
# Include conf/extra/httpd-vhosts.conf
# LoadModule vhost_alias_module modules/mod_vhost_alias.so
2. httpd-vhosts.conf 文件,添加多个站点设置:
##<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host2.example.com
##DocumentRoot "D:/xampp/htdocs/dummy-host2.example.com"
##ServerName dummy-host2.example.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
##</VirtualHost>
根据样例,去掉注释,除DocumentRoot外,dummy-host2.example.com改为自己需要的主机名,例如,www.tp5.com
<VirtualHost *:80>
ServerAdmin webmaster@www.tp5.com
DocumentRoot "D:/xampp/htdocs/tp5/public"
ServerName www.tp5.com
ErrorLog "logs/www.tp5.com-error.log"
CustomLog "logs/www.tp5.com-access.log" common
</VirtualHost>
DocumentRoot的值改为站点对应的目录
3. host文件添加域名解析,例如:127.0.0.1 www.test.com
4. 重启Apache。