我用的是华为云
首先多个域名都解析到公网IP,然后找到httpd.conf。我的是在/etc/httpd/conf,最后在httpd.conf底部加入下边代码
ServerName是你的域名
ServerAlias是带www和不带WWW的解析
DocumentRoot是你的网站目录
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.zhangbeilm.com
ServerAlias zhangbeilm.com *.zhangbeilm.com
DocumentRoot /var/www/html/zhangbeilm
</VirtualHost>
<VirtualHost *:80>
ServerName www.hbxtsq.com
ServerAlias hbxtsq.com *.hbxtsq.com
DocumentRoot /var/www/html
</VirtualHost>
最后重启Apace
service httpd restrat
原文链接:https://www.f2er.com/centos/379745.html