rhet8.2
一:建立两个基于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 ens160 +ipv4.address 192.168.18.100/24 [root@localhost ~]# nmcli connection modify ens160 +ipv4.address 192.168.18.200/24 [root@localhost ~]# nmcli connection up ens160
第二步:创建两个网页的根目录,并定义网页内容
[root@localhost ~]# mkdir -pv /www/ip/{100,200}
mkdir: 已创建目录 '/www'
mkdir: 已创建目录 '/www/ip'
mkdir: 已创建目录 '/www/ip/100'
mkdir: 已创建目录 '/www/ip/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 conf.d]# vim /etc/httpd/conf.d/host.confdocumentRoot /www/ip/100 ServerName 192.168.18.100 documentRoot /www/ip/200 ServerName 192.168.18.200 AllowOverride none Require all granted
第四步:关闭防火墙,重启httpd服务
[root@localhost conf.d]# systemctl stop firewalld [root@localhost conf.d]# setenforce 0 [root@localhost conf.d]# systemctl restart httpd
第五步:验证
[root@localhost conf.d]# curl 192.168.18.100 this is 100 [root@localhost conf.d]# curl 192.168.18.200 this is 200二:
建立两个基于不同端口访问的网站,要求如下:
1、建立一个使用web服务器默认端口的网站,设置documentRoot为/www/port/80,网页内容为:the port is 80。
2、建立一个使用10000端口的网站,设置documentRoot为/www/port/10000,网页内容为:the port is 10000。
步骤:
1.添加一个新的 IP地址
2.创建网页的根目录,并定义两个网页内容
3.定义基于不同的端口来访问网站的配置的文件
4.关闭防火墙,重启httpd服务。
5.验证
[root@localhost ~]# nmcli connection modify ens160 +ipv4.address 192.168.18.18/24
[root@localhost ~]# nmcli connection up ens160
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/5)
[root@localhost ~]# mkdir -pv /www/port/{80,10000}
mkdir: 已创建目录 '/www/port'
mkdir: 已创建目录 '/www/port/80'
mkdir: 已创建目录 '/www/port/10000'
[root@localhost ~]# echo this port is 80 > /www/port/80/index.html
[root@localhost ~]# echo this port is 10000 > /www/port/10000/index.html
[root@localhost ~]# vim /etc/httpd/conf.d/host1.conf
documentRoot /www/port/80
ServerName 192.168.18.18
listen 10000
documentRoot /www/port/10000
ServerName 192.168.18.18
AllowOverride none
Require all granted
~
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# curl 192.168.18.18:80
this port is 80
[root@localhost ~]# curl 192.168.18.18:10000
this port is 10000
三:
建立两个基于域名访问的网站,要求如下:
1、新建一个网站,域名为www.ceshi.com,设置documentRoot为/www/name,网页内容为this is test。
2、新建一个网站,域名为rhce.first.day,同时可通过ce.first.day访问,设置documentRoot为/www/ce,网页内容为:today is first day of class。
第一步:添加新的ip
第二步:创建两个网页文件根目录,并定义网页内容
第三步:定义基于不同域名的网页配置文件
第四步:在Linux中添加域名
第五步:关闭防火墙,重启httpd服务
第六步:验证
[root@localhost ~]# nmcli connection modify ens160 +ipv4.address 192.168.18.180/24
[root@localhost ~]# nmcli connection modify ens160 +ipv4.address 192.168.18.190/24
[root@localhost ~]# nmcli connection up ens160
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/7)
[root@localhost ~]# mkdir -pv /www/{name,ce}
mkdir: 已创建目录 '/www/name'
mkdir: 已创建目录 '/www/ce'
[root@localhost ~]# echo this is test > /www/name/index.html
[root@localhost ~]# echo today is first day of class > /www/ce/index.html
[root@localhost ~]# vim /etc/httpd/conf.d/host2.conf
documentRoot /www/name
ServerName www.ceshi.com
documentRoot /www/ce
ServerName rhce.first.day
ServerName ce.first.day
AllowOverride none
Require all granted
[root@localhost name]# vim /etc/hosts
192.168.18.180 www.ceshi.com
192.168.18.190 rhce.first.day
192.168.18.190 ce.first.day
[root@localhost name]# curl www.ceshi.com
this is test
[root@localhost name]# curl rhce.first.day
today is first day of class
[root@localhost name]# curl ce.first.day
today is first day of class



