2023/7/24 RHEL暑期三(web服务器)

综合练习: 请给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访问

4.开始操作

1.下载"httpd"和“mod_ssl"模块

[root@server ~]# yum install httpd mod_ssl -y

2.创建网页目录

[root@server ~]# mkdir -p /www/openlab
[root@server ~]# echo 'welcome to openlab!!!' > /www/openlab/index.html

设置访问www.openlab.com网站内容为”welcome to openlab!!!"

[root@server ~]# mkdir /www/openlab/student
[root@server ~]# echo 'students' > /www/openlab/student/index.html
[root@server ~]# mkdir /www/openlab/data
[root@server ~]# echo 'data' > /www/openlab/data/index.html
[root@server ~]# mkdir /www/openlab/money
[root@server ~]# echo 'money' > /www/openlab/money/index.html

创建三个子界面分别显示学生信息,教学资料和缴费网站

3.修改/etc/hosts的映射

[root@server ~]# vim /etc/hosts

进入修改hosts文件

在这里插入图片描述
在最后一行写入主机ip地址(192.168.186.130)和网站域名(www.openlab.com)

4.创建网站

[root@server ~]# vim /etc/httpd/conf/httpd.conf 

进入主配置文件编辑
在这里插入图片描述

5.创建song和tian两位学生信息,设置密码访问控制

[root@server ~]# useradd song
[root@server ~]# passwd song
更改用户 song 的密码 。
新的密码: 
无效的密码: 密码少于 8 个字符
重新输入新的密码: 
passwd:所有的身份验证令牌已经成功更新。
[root@server ~]# useradd tian
[root@server ~]# passwd tian
更改用户 tian 的密码 。
新的密码: 
无效的密码: 密码少于 8 个字符
重新输入新的密码: 
passwd:所有的身份验证令牌已经成功更新。
[root@server ~]# htpasswd -c /etc/httpd/passwd song
New password: 
Re-type new password: 
Adding password for user song
[root@server ~]# htpasswd  /etc/httpd/passwd tian
New password: 
Re-type new password: 
Adding password for user tian
[root@server ~]# cat /etc/httpd/passwd
song:$apr1$HaSjm97f$DtVR9R9xUqneuR2SWBC0d1
tian:$apr1$fhQa4001$3zaQ64Oyy9wvdttutE8xs/

6.访问缴费网站实现数据加密基于https访问

(1)创建私钥

[root@server ~]# openssl  genrsa  -aes128  2048  >  /etc/pki/tls/private/money.key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:

(2)创建数字证书

[root@server ~]# openssl  req  -utf8  -new -key  /etc/pki/tls/private/money.key  -x509  -days  365  -out  /etc/pki/tls/certs/money.crt   
Enter pass phrase for /etc/pki/tls/private/money.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:guangdong    
Locality Name (eg, city) [Default City]:guangzhou
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:RHCE
Common Name (eg, your name or your server's hostname) []:server
Email Address []:123@qq.com

7.重启服务

[root@server ~]# systemctl restart httpd

8.验证

请添加图片描述
![请添加图片描述](https://img-blog.csdnimg.cn/eb52ad944dd74c009556e34973d2964e.png请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值