**
实验二:建立两个基于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