• RHCE——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访问。


              1、挂载和安装httpd包、mod_ssl包 

    1. [root@localhost ~]# mount /dev/sr0 /mnt
    2. mount: /mnt: WARNING: device write-protected, mounted read-only.
    3. [root@localhost ~]# vim /etc/yum.repos.d/base.repo
    4. [root@localhost ~]# yum install httpd -y
    5. 正在更新 Subscription Management 软件仓库。
    6. baseos 147 MB/s | 2.4 MB 00:00
    7. AppStream 241 MB/s | 7.5 MB 00:00
    8. Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) 304 kB/s | 53 MB 02:58
    9. Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 345 kB/s | 47 MB 02:19
    10. 依赖关系解决。
    11. ============================================================================================
    12. 软件包 架构 版本 仓库 大小
    13. ============================================================================================
    14. 安装:
    15. httpd x86_64 2.4.37-47.module+el8.6.0+15654+427eba2e.2 rhel-8-for-x86_64-appstream-rpms
    16. 1.4 M
    17. 安装依赖关系:
    18. apr x86_64 1.6.3-12.el8 AppStream 130 k
    19. apr-util x86_64 1.6.1-6.el8 AppStream 105 k
    20. httpd-filesystem noarch 2.4.37-47.module+el8.6.0+15654+427eba2e.2 rhel-8-for-x86_64-appstream-rpms
    21. 41 k
    22. httpd-tools x86_64 2.4.37-47.module+el8.6.0+15654+427eba2e.2 rhel-8-for-x86_64-appstream-rpms
    23. 108 k
    24. mod_http2 x86_64 1.15.7-5.module+el8.6.0+13996+01710940 AppStream 155 k
    25. redhat-logos-httpd noarch 84.5-1.el8 BaseOS 29 k
    26. 安装弱的依赖:
    27. apr-util-bdb x86_64 1.6.1-6.el8 AppStream 25 k
    28. apr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 k
    29. 启用模块流:
    30. httpd 2.4
    31. 事务概要
    32. ============================================================================================
    33. 安装 9 软件包
    34. 总计:2.0 M
    35. 总下载:1.6 M
    36. 安装大小:5.4 M
    37. 下载软件包:
    38. (1/3): httpd-tools-2.4.37-47.module+el8.6.0+15654+427eba2e. 59 kB/s | 108 kB 00:01
    39. (2/3): httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427e 22 kB/s | 41 kB 00:01
    40. (3/3): httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_ 228 kB/s | 1.4 MB 00:06
    41. --------------------------------------------------------------------------------------------
    42. 总计 251 kB/s | 1.6 MB 00:06
    43. Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 4.9 MB/s | 5.0 kB 00:00
    44. 导入 GPG 公钥 0xFD431D51:
    45. Userid: "Red Hat, Inc. (release key 2) "
    46. 指纹: 567E 347A D004 4ADE 55BA 8A5F 199E 2F91 FD43 1D51
    47. 来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    48. 导入公钥成功
    49. 导入 GPG 公钥 0xD4082792:
    50. Userid: "Red Hat, Inc. (auxiliary key) "
    51. 指纹: 6A6A A7C9 7C88 90AE C6AE BFE2 F76F 66C3 D408 2792
    52. 来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    53. 导入公钥成功
    54. 运行事务检查
    55. 事务检查成功。
    56. 运行事务测试
    57. 事务测试成功。
    58. 运行事务
    59. 准备中 : 1/1
    60. 安装 : apr-1.6.3-12.el8.x86_64 1/9
    61. 运行脚本: apr-1.6.3-12.el8.x86_64 1/9
    62. 安装 : apr-util-bdb-1.6.1-6.el8.x86_64 2/9
    63. 安装 : apr-util-openssl-1.6.1-6.el8.x86_64 3/9
    64. 安装 : apr-util-1.6.1-6.el8.x86_64 4/9
    65. 运行脚本: apr-util-1.6.1-6.el8.x86_64 4/9
    66. 安装 : httpd-tools-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 5/9
    67. 运行脚本: httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427eba2e.2.noarch 6/9
    68. 安装 : httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427eba2e.2.noarch 6/9
    69. 安装 : redhat-logos-httpd-84.5-1.el8.noarch 7/9
    70. 安装 : mod_http2-1.15.7-5.module+el8.6.0+13996+01710940.x86_64 8/9
    71. 安装 : httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 9/9
    72. 运行脚本: httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 9/9
    73. 验证 : redhat-logos-httpd-84.5-1.el8.noarch 1/9
    74. 验证 : apr-1.6.3-12.el8.x86_64 2/9
    75. 验证 : apr-util-1.6.1-6.el8.x86_64 3/9
    76. 验证 : apr-util-bdb-1.6.1-6.el8.x86_64 4/9
    77. 验证 : apr-util-openssl-1.6.1-6.el8.x86_64 5/9
    78. 验证 : mod_http2-1.15.7-5.module+el8.6.0+13996+01710940.x86_64 6/9
    79. 验证 : httpd-tools-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 7/9
    80. 验证 : httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 8/9
    81. 验证 : httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427eba2e.2.noarch 9/9
    82. 已更新安装的产品。
    83. 已安装:
    84. apr-1.6.3-12.el8.x86_64
    85. apr-util-1.6.1-6.el8.x86_64
    86. apr-util-bdb-1.6.1-6.el8.x86_64
    87. apr-util-openssl-1.6.1-6.el8.x86_64
    88. httpd-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64
    89. httpd-filesystem-2.4.37-47.module+el8.6.0+15654+427eba2e.2.noarch
    90. httpd-tools-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64
    91. mod_http2-1.15.7-5.module+el8.6.0+13996+01710940.x86_64
    92. redhat-logos-httpd-84.5-1.el8.noarch
    93. 完毕!
    94. [root@localhost ~]# yum install mod_ssl -y
    95. 正在更新 Subscription Management 软件仓库。
    96. 上次元数据过期检查:0:01:41 前,执行于 20221026日 星期三 173529秒。
    97. 依赖关系解决。
    98. ============================================================================================
    99. 软件包 架构 版本 仓库 大小
    100. ============================================================================================
    101. 安装:
    102. mod_ssl x86_64 1:2.4.37-47.module+el8.6.0+15654+427eba2e.2
    103. rhel-8-for-x86_64-appstream-rpms 138 k
    104. 事务概要
    105. ============================================================================================
    106. 安装 1 软件包
    107. 总下载:138 k
    108. 安装大小:266 k
    109. 下载软件包:
    110. mod_ssl-2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64.rp 76 kB/s | 138 kB 00:01
    111. --------------------------------------------------------------------------------------------
    112. 总计 76 kB/s | 138 kB 00:01
    113. 运行事务检查
    114. 事务检查成功。
    115. 运行事务测试
    116. 事务测试成功。
    117. 运行事务
    118. 准备中 : 1/1
    119. 安装 : mod_ssl-1:2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 1/1
    120. 运行脚本: mod_ssl-1:2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 1/1
    121. 验证 : mod_ssl-1:2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64 1/1
    122. 已更新安装的产品。
    123. 已安装:
    124. mod_ssl-1:2.4.37-47.module+el8.6.0+15654+427eba2e.2.x86_64
    125. 完毕!
    126. [root@localhost ~]#

            2、编写配置文件

             3、生成私钥文件

    1. [root@localhost ~]# cd /etc/pki/tls/private
    2. [root@localhost private]# ll
    3. 总用量 0
    4. [root@localhost private]# openssl genrsa -aes128 2048 > openlab.key
    5. Generating RSA private key, 2048 bit long modulus (2 primes)
    6. ............................................................................................................................................................................................................................................................+++++
    7. ............................+++++
    8. e is 65537 (0x010001)
    9. Enter pass phrase:
    10. 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
    11. Enter pass phrase:
    12. 140014132942656:error:2807106B:UI routines:UI_process:processing error:crypto/ui/ui_lib.c:545:while reading strings
    13. Enter pass phrase:
    14. Verifying - Enter pass phrase:
    15. [root@localhost private]# ll
    16. 总用量 4
    17. -rw-r--r--. 1 root root 1766 1026 17:50 openlab.key
    18. [root@localhost private]#

            4、生成证书文件

    1. [root@localhost pki]# cd /etc/pki/tls/certs
    2. [root@localhost certs]# openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key -x509 -days 365 -out openlab.crt
    3. Enter pass phrase for /etc/pki/tls/private/openlab.key:
    4. You are about to be asked to enter information that will be incorporated
    5. into your certificate request.
    6. What you are about to enter is what is called a Distinguished Name or a DN.
    7. There are quite a few fields but you can leave some blank
    8. For some fields there will be a default value,
    9. If you enter '.', the field will be left blank.
    10. -----
    11. Country Name (2 letter code) [XX]:86
    12. State or Province Name (full name) []:ningxia
    13. Locality Name (eg, city) [Default City]:yinchuan
    14. Organization Name (eg, company) [Default Company Ltd]:openlab
    15. Organizational Unit Name (eg, section) []:ce
    16. Common Name (eg, your name or your server's hostname) []:localhost
    17. Email Address []:123
    18. [root@localhost certs]#

            5、创建用户

    1. [root@localhost ~]# htpasswd -c /etc/httpd/users song
    2. New password:
    3. Re-type new password:
    4. Adding password for user song
    5. [root@localhost ~]# htpasswd -c /etc/httpd/users tian
    6. New password:
    7. Re-type new password:
    8. Adding password for user tian

            6、创建目录

            7、定义网页文件内容

    1. [root@localhost ~]# echo Welcome to openlab > /www/openlab/index.html
    2. [root@localhost ~]# echo 学生信息 > /openlab/student/index.html
    3. [root@localhost ~]# echo 教学资料 > /openlab/data/index.html
    4. [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”

  • 相关阅读:
    Flutter 与 Dart 的市场应用
    [附源码]Python计算机毕业设计Django二次元信息分享平台的设计及实现
    Linux如何安装Maven?
    网页一直跳转到国家反诈中心页面
    【前置句与倒装句练习题】否定词放句首的倒装
    复习单片机:定时器/计数器部分(内含:1.51 单片机定时器原理 +2.51 单片机定时/计数器结构+3.定时器配置+4.代码部分+5.实验现象)
    运营商IMS网间互联互通组网关键技术研究
    分布式调用与高并发处理(二)| Dubbo
    【SQL server速成之路】触发器
    关于RISC-V安全性的全面综述
  • 原文地址:https://blog.csdn.net/wzpny/article/details/127543311