2021-07-25

**

实验二:建立两个基于ip地址访问的网站,要求如下: 1、该网站ip地址的主机位为100,设置DocumentRoot为/www/ip/100,网页内容为:this is 100。 2、该网站ip地址主机位为200,设置DocumentRoot为/www/ip/200,网页内容为:this is 200。

**

第一步,先添加两个ip地址

[root@localhost ~]#nmcli connection modify eno16777736 +ipv4.addresses 192.168.9.100.100/24 ipv4.gateway

192.168.9.1 ipv4.method manual connection.autoconnect yes //手动添加地址

[root@localhost ~]# nmcli connection modify eno16777736 +ipv4.addresses 192.168.9.200/24

[root@localhost ~]# nmcli connection up eno16777736 //启动网卡
在这里插入图片描述

第二步,创建两个网页文件根目录,并定义网页内容

[root@localhost ~]# mkdir -pv /www/ip/{100,200}

[root@localhost ~]# echo this is 100 > /www/ip/100/index.html 定义网页目录的内容在这里插入图片描述

[root@localhost ~]# echo this is 200 > /www/ip/200/index.html

第三步,定义基于不同ip地址来访问网站的配置文件

(示例文件[root@localhost ~]# vim /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf )

[root@localhost ~]# vim /etc/httpd/conf.d/host.conf //编译配置文件

[root@localhost ~]# systemctl restart httpd //重启服务,每次编辑完配置文件都需要重启服务

[root@localhost ~]# curl 192.168.126.200 //这条命令可以手动查看网页内容

this is 200
[root@localhost ~]# curl 192.168.126.100

this is 100

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值