■虚拟Web主机
●在同一台服务器中运行多个Web站点,其中每一一个站点并不独立
占用一台真正的计算机
■httpd支持的虚拟主机类型
●基于域名的虚拟主机
●基于IP地址的虚拟主机
●基于端口的虚拟主机:
●构建2个虚拟Web站点
www.kgc.com, IP地址为173.17.17.11
www.kcce.com, IP地址为173.17.17.11
●在浏览器中访问这两个域名时,分别显示不同的内容
1.为虚拟主机提供域名解析
[root@dnssvr ~]# vim /var/named/chroot/var/named/kgc.com.zone
@ IN NS dnssvr.kgc.com.
dnssvr IN A 173.1 7.1 7.2
www IN A 173.17.17.11
[root@dnssvr ~]# vim /var/named/chroot/var/named/kcce.com.zone
......
@ IN NS dnssvr.kgc.com.
www IN A 173.17.1711
2.为虚拟主机准备网页文档
[root@www ~]# mkdir -p /var/www/html/kgc
[root@www ~]# mkdir -p /var/www/html/accp
[root@www ~]# echo " <h2>www.kgc.com</h2>" >
/var/www/html/kgccom/index.html
[root@www ~]# echo
! <h2>www.accp.com</h2>" >
/var/www/html/kccecom/index.html
3.添加虚拟主机配置
[root@www ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.comf
<VirtualHost :80>
DocumentRoot "/var/www/html/kgccom"
ServerName www.kgc.com
ErrorLog "logs/www.kgc.com.error_log"
CustomLog "logs/www.kgc.com.access_log" common
< Directory "/var/www/html" >
Require all granted
</Directory>
</VirtualHost>
<VirtualHost :80>
DocumentRoot "/var/www/html、accp
ServerName www.accp.com
ErrorLog "logs/www.accp.com.error_log"
CustomLog "logs/www.accp.com.access_log" common
< Directory "/var/www/html" >
Require all granted
</Directory>
< /VirtualHost>
4.在客户机分别访问虚拟Web主机
●构建2个虚拟Web站点
www.kgc.com, IP地址、 端口为173.17.17.11:80
www.accp.com, IP地址、 端口为173.17.17.11:8353
在浏览器中访问这两个端口时,分别显示不同的内容
[root@www ~]# vim /usr/loca/httpd/conf/extra/httpd-vhosts.conf
< VirtualHost 173.17.17.11:80习
DocumentRoot "/var/wwwhtml/kccecom"
ServerName www.kgc.com
</VirtualHost>
<VirtualHost 173.17.17.11:8353)
DocumentRoot "/var/www/html/kccepad"
ServerName www.accp.com
< NirtualHost>
Listen 80
Listen 8353
■应用示例:
●构建2个虚拟Web站点
www.kgc.com, IP地址为220.181.120.61
www.kcce.com, IP地址为122.115.32.133
在浏览器中访问这两个IP时P分别显示不同的内容
[root@www ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
< VirtualHost 220.181.120.61:80>
DocumentRoot "/var/www/html/kgccom"
ServerName www.kgc.com
</NirtualHost> I
<VirtualHost 122.115.32.133:80>
DocumentRoot "/var/www/htm/kccecom"
ServerName www.kcce.com
</VirtualHost>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。