通过搭建web服务来实现页面访问

练习题:
1、要求搭建web服务器,能够访问在网页内容为“小胖,你咋这么胖呢!”
2、要求搭建web服务器,创建基于域名的虚拟机,能够使用www.xiaopang.com和www.dapang.com访问各自的网站存放路径分别为/xiaopang和/dapang,内容自定。
3、创建虚拟目录真实物理位置在/usr/local/hehe,内容自定
4、创建虚拟目录真实物理位置在/usr/local/maomao,内容自定,但允许abc 和xyz用户通过密码访问。
综合练习:请给openlab搭建web网站
网站需求:
1、基于域名wwwopenlab.com可以访问网站内容为 welcome to openlab!!!
2、给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student网站访问学生信息,www.openlab.com/data网站访问教学资料,www.openlab.com/money网站访问缴费网站。
3、要求:
(1)学生信息网站只有song和tian两个可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于https访问。

操作:

1、要求搭建web服务器,能够访问在网页内容为“小胖,你咋这么胖呢!”
vim /etc/httpd/conf.d/vhosts.conf
在这里插入图片描述

[root@localhost ~]# mkdir /xiaopang
[root@localhost ~]# echo 小胖,你咋这么胖呢! > /xiaopang/index.html
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0

在这里插入图片描述
2、要求搭建web服务器,创建基于域名的虚拟机,能够使用www.xiaopang.com和www.dapang.com访问各自的网站存放路径分别为/xiaopang和/dapang,内容自定。

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

在这里插入图片描述

[root@localhost ~]# mkdir /dapang
[root@localhost ~]# echo 大家好,我是dapang  > /dapang/index.html
[root@localhost ~]# mkdir /xiaopang
[root@localhost ~]# echo 小胖,你咋这么胖呢! > /xiaopang/index.html
[root@localhost ~]# systemctl restart httpd
linux的地址解析:路径  vim /etc/hosts

在这里插入图片描述
windows的本地解析地址:此电脑—C盘----Windows-----System32—drivers----etc----hosts–Notepad++打开
在这里插入图片描述
在这里插入图片描述
保存在这里插入图片描述
请添加图片描述
访问:www.xiaopang.com
www.dapang.com
在这里插入图片描述
在这里插入图片描述
3、创建虚拟目录真实物理位置在/usr/local/hehe,内容自定

 [root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

在这里插入图片描述

[root@localhost ~]# mkdir /usr/local/haha
 [root@localhost ~]# echo this is haha >/usr/local/haha/index.html
[root@localhost ~]# systemctl restart httpd                    

访问:
在这里插入图片描述
4、创建虚拟目录真实物理位置在/usr/local/maomao,内容自定,但允许abc 和xyz用户通过密码访问。

 [root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

在这里插入图片描述

[root@localhost ~]# htpasswd -c /usr/local/maomao  abc
New password: 
Re-type new password: 
Adding password for user abc

[root@localhost ~]# htpasswd  /usr/local/maomao  xyz
New password: 
Re-type new password: 

在这里插入图片描述
综合练习:请给openlab搭建web网站
网站需求:
1、基于域名www.openlab.com可以访问网站内容为 welcome to openlab!
2、给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student网站访问学生信息,www.openlab.com/data网站访问教学资料,www.openlab.com/money网站访问缴费网站。
3、要求:
(1)学生信息网站只有song和tian两个可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于https访问。

操作:

1、

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

在这里插入图片描述

[root@localhost ~]# mkdir /openlab
[root@localhost ~]# echo Welcome to openlab! > /openlab/index.html
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# vim /etc/hosts
里面写的内容:
192.168.232.130    www.openlab.com

在这里插入图片描述
访问:
在这里插入图片描述

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf

在这里插入图片描述

[root@localhost ~]# mkdir /openlab/student
[root@localhost ~]# echo 这是学生信息表 > /openlab/student/index.html
[root@localhost ~]# mkdir /openlab/data
[root@localhost ~]# echo 这是该学校的教学资料  > /openlab/data/index.html
[root@localhost ~]# mkdir /openlab/money
[root@localhost ~]# echo 这个是学校的缴费网站 > /openlab/money/index.html
给/openlab/money颁发自签的证书:
[root@localhost ~]# cd /etc/pki/tls/certs/
[root@localhost certs]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout ../private/openlab.key -x509 -days 365 -out  openlab.crt
[root@localhost certs]# openssl genrsa -aes128 2048 >openlab.key
Enter pass phrase:
Verifying - Enter pass phrase:
[root@localhost ~]# systemctl restart httpd

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值