含义:
不同域名访问不同的页面
配置步骤:
1.vim /etc/hosts ##编辑本地解析
172.25.254.100 music.westos.com news.westos.com
2.mkdir /var/www/virtual/news/html -p ##建立news发布目录
3.vim /var/www/virtual/news/html/index.html ##编辑news发布文件
<h1>new's page</h1>
4.mkdir /var/www/virtual/music/html -p ##建立music发布目录
5.vim /var/www/virtual/music/html/index.html ##编辑music发布文件
</h1>music's page</h1>
6.cd /etc/httpd/conf.d/ ##切换到子配置目录
7.vim a_default.conf ##编辑默认访问文件,没有声明的都访问这个文件,默认虚拟主机
<Virtualhost _default_:80> ##默认端口为80
DocumentRoot /var/www/html ##默认访问此目录,默认的意思是没有声明
CustomLog logs/default.log combined ##logs表示/etc/httpd/logs combined表示混合型日志。
</Virtualhost>
8.vim news.conf ##指定名称的虚拟主机
<Virtualhost *:80> ##默认端口为80
ServerName news.westos.com ##特殊指定就访问特殊指定页面
DocumentRoot /var/www/virtual/news/html
CustomLog logs/news.log combined
</Virtualhost>
<Directory "/var/www/virtual/news/html"> ##授权
Require all granted
</Directory>
9.vim music.conf ##指定名称的虚拟主机
<Virtualhost *:80> ##默认端口为80
ServerName music.westos.com ##特殊指定就访问特殊指定的页面
DocumentRoot /var/www/virtual/music/html
CustomLog logs/music.log combined
</Virtualhost>
<Directory "/var/www/virtual/music/html">
Require all granted
</Directory>
测试:在浏览器上面输入
news.westos.com
music.westos.com
结果:不同域名显示不同页面