• 搭建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、挂载光盘,配置yum源,安装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

    2、关闭防火墙和selinux

    1. [root@localhost ~]# systemctl stop firewalld.service
    2. [root@localhost ~]# setenforce 0

    3、更改配置文件实现自定义设置

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

    4、生成私钥文件

    1. [root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
    2. [root@localhost ~]# cd /etc/pki/tls/private
    3. [root@localhost private]# ll
    4. 总用量 0
    5. [root@localhost private]# openssl genrsa -aes128 2048 > openlab.key
    6. Generating RSA private key, 2048 bit long modulus (2 primes)
    7. ...............................................................................+++++
    8. .........................................................................................+++++
    9. e is 65537 (0x010001)
    10. Enter pass phrase:
    11. Verifying - Enter pass phrase:
    12. [root@localhost private]# ll
    13. 总用量 4
    14. -rw-r--r--. 1 root root 1766 1027 20:52 openlab.key

    5、生成证书文件

    1. [root@localhost private]# 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) []:cyg
    16. Common Name (eg, your name or your server's hostname) []:localhost
    17. Email Address []:admin

    6、根据配置创建资源文件

    (1)创建用户

    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

    (2)创建目录

    1. [root@localhost ~]# mkdir -p /www/openlab
    2. [root@localhost ~]# mkdir -pv /openlab/student
    3. mkdir: 已创建目录 '/openlab'
    4. mkdir: 已创建目录 '/openlab/student'
    5. [root@localhost ~]# mkdir -pv /openlab/data
    6. mkdir: 已创建目录 '/openlab/data'
    7. [root@localhost ~]# mkdir -pv /openlab/money
    8. mkdir: 已创建目录 '/openlab/money'

    (3)创建测试文件

    1. [root@localhost ~]# echo Welcome to openlab > /www/openlab/index.html
    2. [root@localhost ~]# echo student information > /openlab/student/index.html
    3. [root@localhost ~]# echo resources material > /openlab/data/index.html
    4. [root@localhost ~]# echo payment channel > /openlab/money/index.html

    7、更改hosts,添加所需域名

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

    8、对Windows下C:\Windows\System32\drivers\etc\hosts域名解析

    9、重启服务

    1. [root@localhost ~]# systemctl restart httpd
    2. Enter TLS private key passphrase for www.openlab.com:443 (RSA) : ******

     输入密钥的密码

    10、使用Windows网页测试

    (1)测试“www.openlab.com”

       (2)测试“www.openlab.com/student”

     

     

     

    (3)测试“www.openlab.com/data”

    (4)测试“www.openlab.com/money”

     

  • 相关阅读:
    【Sprig AOP】
    阿里云国际站代理商:利用RDS MySQL数据库云开发ToDo List
    自由职业者的福音来啦!人工智能带你智能规划,做你所擅长的事情
    鼠标拖拽围绕某个物体旋转展示
    MySQL进阶篇(2)—SQL优化、视图/存储过程/触发器
    # 磁盘引导方式相关知识之BIOS、msdos、MBR、UEFI、gpt、esp、csm
    19.2 容器分类、array、vector容器精解
    《计算机病毒技术及其防御》 第一章 课后练习详解
    SystemVerilog学习(3)——数组
    STL 中元素删除相关算法
  • 原文地址:https://blog.csdn.net/CYG2573076485/article/details/127561666