Linux平台 apache绑定多个域名设置

打开http.conf
 
1,#ServerName 127.0.0.1 修改成ServerName 110.220.330.440:80  (记得去掉前面有#号)
 
2,NameVirtualHost *   修改成"NameVirtualHost 110.220.330.440:80"
 
3,在文件最后面添加:
 
NameVirtualHost 110.220.330.440:80
 
<VirtualHost 110.220.330.440:80>
DocumentRoot /var/www/html
ServerName   103.254.108.90
</VirtualHost>
 
<VirtualHost 110.220.330.440:80>
DocumentRoot /var/www/html/a  //网站目录为a
ServerName   a.com
ServerAlias  www.a.com  //支持别名www访问
ErrorLog logs/a.com-error_log
CustomLog logs/a.com-access_log common
</VirtualHost>
 
<VirtualHost 110.220.330.440:80>
DocumentRoot   /var/www/html/b  //网站目录为b
ServerName   b.com
ServerAlias  www.b.com  //支持别名www访问
</VirtualHost>