这篇文章将为大家详细讲解有关web网站服务基于ip,端口,域名的示例分析,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
基于ip
yum install httpd -y
service httpd start
chkconfig httpd on
vi /etc/httpd/conf/httpd.conf
# Document
<VirtualHost 192.168.100.100:80>
ServerName www.benet.com
DocumentRoot /www/benet.com
</VirtualHost>
<VirtualHost 192.168.100.110:80>
ServerName www.accp.com
DocumentRoot /www/accp.com
</VirtualHost>
mkdir -pv /www/{benet.com,accp.com}
cd /www/benet.com/
vi index.html
<title>benet</title>
<h2>www.benet.com</h2>
cd ..
cd accp.com/
vi index.html
<title>accp</title>
<h2>www.accp.com</h2>
service httpd restart
ip address add 192.168.100.100/24 dev eth0
ip address add 192.168.100.110/24 dev eth0
ip addr show
基于端口
vi /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.100.100:80>
ServerName www.benet.com
DocumentRoot /www/benet.com
</VirtualHost>
<VirtualHost 192.168.100.110:8080>
ServerName www.huawei.com
DocumentRoot /www/huawei.com
</VirtualHost>
<VirtualHost 192.168.100.100:80>
ServerName www.benet.com
DocumentRoot /www/benet.com
</VirtualHost>
cd /www/
mkdir huawei.com
cd huawei.com/
vi index.html
<title>huawei</title>
<h2>www.huawei.com</title>
service httpd restart
vi /etc/httpd/conf/httpd.conf
#Listen 12.34.56.78:80
Listen 80
Listen 8080
service httpd restart
基于域名
view/etc/httpd/conf.d/virtual.conf
nameVirtualHost 192.168.100.110:80
<VirtualHost 192.168.100.110:80>
ServerName blog.csdn.net
DocumentRoot /www/csdn.net
</VirtualHost>
mkdir -p /www/csdn.net/
cd /www/csdn.net/
vi index.html
<title>csdn</title>
<h2>blog.csdn.com</h2>
service httpd restart
win7 windows/systrm32/drivers/etc/hosts
192.168.100.110 www.accp.com
192.168.100.110 blogs.csdn.net
关于web网站服务基于ip,端口,域名的示例分析就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。