给openlab搭建web网站

网站需求:
1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab.
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料
www.openlab.com/money网站访问缴费网站。
要求:(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
(2)访问缴费网站实现数据加密基于https访问。

[root@localhost ~]# yum install httpd -y    #下载http软件包
[root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf    #修改配置文件

在这里插入图片描述

[root@localhost ~]# vim /etc/hosts     #手动修改文件,添加域名关联信息

在这里插入图片描述
客户端测试手动添加域名关联信息 window C:\Windows\System32\drivers\etc\hosts
在这里插入图片描述

[root@localhost ~]# mkdir /openlab   #创建目录
[root@localhost ~]# echo welcome to openlab > /openlab/index.html   
[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# cat /openlab/index.html
welcome to openlab
[root@localhost ~]# curl http://www.openlab.com
welcome to openlab

在这里插入图片描述

[root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf    #修改配置文件

在这里插入图片描述

[root@localhost ~]# mkdir /openlab/{student,data,money} -pv
[root@localhost ~]# echo I am a student > /openlab/student/index.html
[root@localhost ~]# echo You are a data > /openlab/data/index.html
[root@localhost ~]# echo It is a money > /openlab/money/index.html
[root@localhost ~]# htpasswd -c /etc/httpd/user song

在这里插入图片描述
[root@localhost ~]# htpasswd /etc/httpd/user tian
在这里插入图片描述

[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# cat /openlab/student/index.html
I am a student
[root@localhost ~]# cat /openlab/data/index.html
You are a data
[root@localhost ~]# curl http://www.openlab.com/student/ -u song

在这里插入图片描述

[root@localhost ~]# curl http://www.openlab.com/student/ -u tian

在这里插入图片描述
在Linux主机上访问http://www.openlab.com 输入用户名和密码进去访问(song和tianjunke)
在这里插入图片描述
在这里插入图片描述

[root@localhost ~]# yum install mod_ssl.x86_64 -y
[root@localhost certs]# vim /etc/httpd/conf.d/vhost.conf 

在这里插入图片描述

[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# cat /openlab/money/index.html
It is a money
[root@localhost ~]# systemctl restart httpd
Job for httpd.service failed because the control process exited with error code.
See "systemctl status httpd.service" and "journalctl -xe" for details.  

因为我没有openlab加密证书,所以我重启服务失败,接下来搭建openlab加密证书文件

[root@localhost private]# cd /etc/pki/tls/certs/
[root@localhost certs]# cd ../private/
[root@localhost private]# openssl genrsa -aes128 2048 > openlab.key
[root@localhost private]# cd ../certs/
[root@localhost certs]# openssl req -utf8 -key /etc/pki/tls/private/openlab.key -x509 -days 365 -out openlab.crt

详细步骤在我<https(web)搭建加密文件>这篇博客里

[root@localhost certs]# systemctl restart httpd
Enter TLS private key passphrase for www.openlab.com:443 (RSA) : ******
[root@localhost certs]# curl http://www.openlab.com/money/
It is a money
[root@localhost certs]# curl http://www.openlab.com/data/
You are a data

在Linux主机上访问http://www.openlab.com/data/
在这里插入图片描述
在Linux主机上访问http://www.openlab.com/money/
在这里插入图片描述

再把学生信息写入www.openlab.com/student 网站,把教学资料写入www.openlab.com/data网站,把缴费写入www.openlab.com/money网站。

这样就成功啦!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值