• Linux:给openlab搭建web网站


    httpd服务器建立综合练习

    建立网站需求:

    1.基于域名 www.openlab.com 可以访问网站内容为 welcome to openlab!!!
    2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,

    (1)、基于 www.openlab.com/student 网站访问学生信息,
    (2)、基于 www.openlab.com/data 网站访问教学资料
    (3)、基于 www.openlab.com/money 网站访问缴费网站。

    3.要求

    (1)学生信息网站只有 song 和 tian 两个用户可以访问,其他用户不能访问。
    (2)访问缴费网站实现数据加密基于 https 访问。

    步骤如下:
    1、安装httpd、ssl_mod。先完成第一题:
    [root@CE ~]# cd /etc/httpd/conf.d/
    [root@CE conf.d]# vim openlab.conf  //内容截图如下
    [root@CE conf.d]# cd /
    [root@CE /]# mkdir labweb
    [root@CE /]# echo "welcome to openlab!!!"  >  /labweb/index.html
    [root@CE /]# vim /etc/hosts 	//编辑内容截图如下
    [root@CE /]# systemctl stop firewalld.service
    [root@CE /]# setenforce 0
    [root@CE conf.d]# systemctl restart httpd
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    配置文件内的编辑内容截图:

    vim /etc/httpd/conf.d/openlab.conf
    
    • 1

    在这里插入图片描述

    vim /etc/hosts
    
    • 1

    在这里插入图片描述

    完成截图:

    在这里插入图片描述

    2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站。

    (1)、基于 www.openlab.com/student 网站访问学生信息。(学生信息网站只有 song 和 tian 两个用户可以访问,其他用户不能访问。)

    [root@CE /]# cd /etc/httpd/conf.d
    [root@CE conf.d]# htpasswd -c /etc/httpd/student song
    New password: 	//密码输个简单的就行
    Re-type new password:
    Adding password for user song
    [root@CE conf.d]# htpasswd /etc/httpd/student tian
    New password:
    Re-type new password:
    Adding password for user tian
    [root@CE conf.d]# vim openlab.conf		//编写内容如下截图:
    [root@CE conf.d]# cd /labweb/
    [root@CE labweb]# mkdir student
    [root@CE labweb]# echo "welcome to student!!!" > student/index.html
    [root@CE labweb]# systemctl restart httpd
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    vim /etc/httpd/conf.d/openlab.conf
    
    • 1

    在这里插入图片描述

    完成截图:

    在这里插入图片描述
    用户名输入song或者tian
    密码输入自己设置的密码就行了

    在这里插入图片描述
    (2)、基于 www.openlab.com/data 网站访问教学资料。

    [root@CE labweb]# vim /etc/httpd/conf.d/openlab.conf		//截图如下:
    [root@CE labweb]# mkdir date
    [root@CE labweb]# echo 'welcome to date!!!' > date/index.html            
     [root@CE labweb]# systemctl restart httpd
    
    • 1
    • 2
    • 3
    • 4
    [root@CE labweb]# vim /etc/httpd/conf.d/openlab.conf
    
    • 1

    在这里插入图片描述

    完成截图:

    在这里插入图片描述

    (3)、基于 www.openlab.com/money 网站访问缴费网站。
    [root@CE labweb]# cd /etc/pki/tls/certs/
    [root@CE certs]# ls
    ca-bundle.crt        jiami.crt      mysecret.crt
    ca-bundle.trust.crt  localhost.crt  yuan.crt
    [root@CE certs]# openssl genrsa > openlab.key
    [root@CE certs]# openssl req -utf8 -new -key openlab.key -x509 -days 100 -out openlab.crt
    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) []:chongqing
    Locality Name (eg, city) [Default City]:chongqing
    Organization Name (eg, company) [Default Company Ltd]:chengke
    Organizational Unit Name (eg, section) []:rhce
    Common Name (eg, your name or your server's hostname) []:www.openlab.com
    Email Address []:admin@123
    
    
    [root@CE certs]# mv openlab.key ../private/
    [root@CE certs]# vim /etc/httpd/conf.d/openlab.conf
    
    [root@CE certs]# systemctl restart httpd
    
    [root@CE certs]# cd /labweb/
    [root@CE labweb]# mkdir money
    [root@CE labweb]# echo 'welcome to money!!!' > money/index.html
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    openlab.conf  		//配置文件
    
    • 1

    在这里插入图片描述

    完成截图:

    在这里插入图片描述
    所有要求就完成啦!! 开心吧

    还有一点内容就是在Windows主机hosts文件添加www.openlab.com的域名地址我就没给出步骤,因为简单。

  • 相关阅读:
    Linux软硬连接与动静态库
    fastadmin插件 shopro 商城支付配置
    Redis 好友关注-朋友圈
    threejs: layers实现图层的显示隐藏切换
    2022年安全员-B证试题及模拟考试
    网络安全(黑客)—2024自学
    2023年03月 Python(一级)真题解析#中国电子学会#全国青少年软件编程等级考试
    vue3+ts 组合式api中(setup)如何使用getCurrentInstance,以及用它替代this
    二叉排序树(BST)和平衡二叉树(AVL)基础概念
    CAN总线
  • 原文地址:https://blog.csdn.net/qq_63890458/article/details/134375764