修改httpd.conf的Include项来指定虚拟主机配置文件路径
编辑httpd-vhosts.conf虚拟主机配置文件
<VirtualHost *:80>
DocumentRoot "/var/www/html" #指定站点目录
ServerName www.abc.com #访问的域名
ErrorLog logs/www.abc.com.error_log #错误日志的存放路径
CustomLog logs/www.abc.com.access_log common #访问日志的存放路径
</VirtualHost>
然后重启服务,但是我在重启的过程中出现了报错
[Thu May 03 13:46:14 2018] [warn] default VirtualHost overlap on port 80, the first has precedence
[Thu May 03 13:46:14 2018] [warn] default VirtualHost overlap on port 80, the first has precedence.
这个报错是说明并没有真正的应用到这些虚拟主机,需要在httpd.conf配置文件中修改,把NameVirtualHost项前面的注释去掉就可以了
原文地址:http://blog.51cto.com/13444271/2112119