综合练习:请给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、挂载和安装httpd包、mod_ssl包
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# vim /etc/yum.repos.d/base.repo
[root@localhost ~]# yum install httpd -y
正在更新 Subscription Management 软件仓库。
baseos 147 MB/s | 2.4 MB 00:00
AppStream 241 MB/s | 7.5 MB 00:00
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) 304 kB/s | 53 MB 02:58
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 345 kB/s | 47 MB 02:19
依赖关系解决。
============================================================================================
软件包 架构 版本 仓库 大小
============================================================================================
安装:
httpd x86_64 2.4.37-47.module+el8.6.0+15654+427eba2e.2 rhel-8-for-x86_64-appstream-rpms
1.4 M
安装依赖关系:
apr x86_64 1.6.3-12.el8 AppStream 130 k
apr-util x86_64 1.6.1-6.el8 AppStream 105 k
httpd-filesystem noarch 2.4.37-47.module+el8.6.0+15654+427eba2e.2 rhel-8-for-x86_64-appstream-rpms
41 k
httpd-tools x86_64 2.4.37-47.module+el8.6.0+15654+427eba2e.2 rhel-8-for-x86_64-appstream-rpms
108 k
mod_http2 x86_64 1.15.7-5.module+el8.6.0+13996+01710940 AppStream 155 k
redhat-logos-httpd noarch 84.5-1.el8 BaseOS 29 k
安装弱的依赖:
apr-util-bdb x86_64 1.6.1-6.el8 AppStream 25 k
apr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 k
启用模块流:
httpd 2.4
事务概要
============================================================================================
安装 9 软件包
总计:2.0 M
总下载:1.6 M
安装大小:5.4 M
下载软件包:
(1/3): httpd-tools-2.4.37-47.module+el8.6.0+15654+427eba2e. 59 kB/s | 108 kB 00:01
(2/3): httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427e 22 kB/s | 41 kB 00:01
(3/3): httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_ 228 kB/s | 1.4 MB 00:06
--------------------------------------------------------------------------------------------
总计 251 kB/s | 1.6 MB 00:06
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 4.9 MB/s | 5.0 kB 00:00
导入 GPG 公钥 0xFD431D51:
Userid: "Red Hat, Inc. (release key 2) <security@redhat.com>"
指纹: 567E 347A D004 4ADE 55BA 8A5F 199E 2F91 FD43 1D51
来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
导入公钥成功
导入 GPG 公钥 0xD4082792:
Userid: "Red Hat, Inc. (auxiliary key) <security@redhat.com>"
指纹: 6A6A A7C9 7C88 90AE C6AE BFE2 F76F 66C3 D408 2792
来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : apr-1.6.3-12.el8.x86_64 1/9
运行脚本: apr-1.6.3-12.el8.x86_64 1/9
安装 : apr-util-bdb-1.6.1-6.el8.x86_64 2/9
安装 : apr-util-openssl-1.6.1-6.el8.x86_64 3/9
安装 : apr-util-1.6.1-6.el8.x86_64 4/9
运行脚本: apr-util-1.6.1-6.el8.x86_64 4/9
安装 : httpd-tools-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 5/9
运行脚本: httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427eba2e.2.noarch 6/9
安装 : httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427eba2e.2.noarch 6/9
安装 : redhat-logos-httpd-84.5-1.el8.noarch 7/9
安装 : mod_http2-1.15.7-5.module+el8.6.0+13996+01710940.x86_64 8/9
安装 : httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 9/9
运行脚本: httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 9/9
验证 : redhat-logos-httpd-84.5-1.el8.noarch 1/9
验证 : apr-1.6.3-12.el8.x86_64 2/9
验证 : apr-util-1.6.1-6.el8.x86_64 3/9
验证 : apr-util-bdb-1.6.1-6.el8.x86_64 4/9
验证 : apr-util-openssl-1.6.1-6.el8.x86_64 5/9
验证 : mod_http2-1.15.7-5.module+el8.6.0+13996+01710940.x86_64 6/9
验证 : httpd-tools-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 7/9
验证 : httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 8/9
验证 : httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427eba2e.2.noarch 9/9
已更新安装的产品。
已安装:
apr-1.6.3-12.el8.x86_64
apr-util-1.6.1-6.el8.x86_64
apr-util-bdb-1.6.1-6.el8.x86_64
apr-util-openssl-1.6.1-6.el8.x86_64
httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64
httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427eba2e.2.noarch
httpd-tools-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64
mod_http2-1.15.7-5.module+el8.6.0+13996+01710940.x86_64
redhat-logos-httpd-84.5-1.el8.noarch
完毕!
[root@localhost ~]# yum install mod_ssl -y
正在更新 Subscription Management 软件仓库。
上次元数据过期检查:0:01:41 前,执行于 2022年10月26日 星期三 17时35分29秒。
依赖关系解决。
============================================================================================
软件包 架构 版本 仓库 大小
============================================================================================
安装:
mod_ssl x86_64 1:2.4.37-47.module+el8.6.0+15654+427eba2e.2
rhel-8-for-x86_64-appstream-rpms 138 k
事务概要
============================================================================================
安装 1 软件包
总下载:138 k
安装大小:266 k
下载软件包:
mod_ssl-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64.rp 76 kB/s | 138 kB 00:01
--------------------------------------------------------------------------------------------
总计 76 kB/s | 138 kB 00:01
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : mod_ssl-1:2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 1/1
运行脚本: mod_ssl-1:2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 1/1
验证 : mod_ssl-1:2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 1/1
已更新安装的产品。
已安装:
mod_ssl-1:2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64
完毕!
[root@localhost ~]#
2、编写配置文件
3、生成私钥文件
[root@localhost ~]# cd /etc/pki/tls/private
[root@localhost private]# ll
总用量 0
[root@localhost private]# openssl genrsa -aes128 2048 > openlab.key
Generating RSA private key, 2048 bit long modulus (2 primes)
............................................................................................................................................................................................................................................................+++++
............................+++++
e is 65537 (0x010001)
Enter pass phrase:
140014132942656:error:28078065:UI routines:UI_set_result_ex:result too small:crypto/ui/ui_lib.c:905:You must type in 4 to 1023 characters
Enter pass phrase:
140014132942656:error:2807106B:UI routines:UI_process:processing error:crypto/ui/ui_lib.c:545:while reading strings
Enter pass phrase:
Verifying - Enter pass phrase:
[root@localhost private]# ll
总用量 4
-rw-r--r--. 1 root root 1766 10月 26 17:50 openlab.key
[root@localhost private]#
4、生成证书文件
[root@localhost pki]# cd /etc/pki/tls/certs
[root@localhost certs]# openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key -x509 -days 365 -out openlab.crt
Enter pass phrase for /etc/pki/tls/private/openlab.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) []:ningxia
Locality Name (eg, city) [Default City]:yinchuan
Organization Name (eg, company) [Default Company Ltd]:openlab
Organizational Unit Name (eg, section) []:ce
Common Name (eg, your name or your server's hostname) []:localhost
Email Address []:123
[root@localhost certs]#
5、创建用户
[root@localhost ~]# htpasswd -c /etc/httpd/users song
New password:
Re-type new password:
Adding password for user song
[root@localhost ~]# htpasswd -c /etc/httpd/users tian
New password:
Re-type new password:
Adding password for user tian
6、创建目录
7、定义网页文件内容
[root@localhost ~]# echo Welcome to openlab > /www/openlab/index.html
[root@localhost ~]# echo 学生信息 > /openlab/student/index.html
[root@localhost ~]# echo 教学资料 > /openlab/data/index.html
[root@localhost ~]# echo 缴费通道 > /openlab/money/index.html
8、修改hosts文件
[root@localhost ~]# vim /etc/hosts
9、测试
1)、网页测试“http://www.openlab.com”
2)、网页测试“http://www.openlab.com/student”
3)、网页测试“http://www.openlab.com/data”
4)、网页测试“http://www.openlab.com/money”