• 给openlab搭建web网站


    1.作业的要求

    2.访问www.openlab.com网站

    2.1先准备好相关的包和关闭防火墙等操作

    1. mount /dev/sr0 /mnt/ //先挂载
    2. yum install httpd -y //下载htppd
    3. systemctl stop firewalld //关闭防火墙
    4. setenforce 0

    2.2然后开始配置文件和仓库

    这一步比较关键,之前改了接口什么的的建议改回来不然会一直404找不到服务

    1. [root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf
    2. [root@localhost ~]# cat /etc/httpd/conf.d/vhost.conf
    3. <Directory /www/>
    4. AllowOverride none
    5. Require all granted
    6. </Directory>
    7. <VirtualHost 192.168.171.129:80>
    8. Servername www.openlab.com
    9. DocumentRoot /var/www/openlab
    10. </VirtualHost>
    11. [root@localhost ~]# mkdir /var/www/openlab
    12. [root@localhost ~]# echo 1111 > /var/www/openlab/index.html
    13. [root@localhost conf.d]# vim /etc/hosts
    14. [root@localhost conf.d]# cat /etc/hosts
    15. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    16. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
    17. 192.168.171.129 www.openlab.com
    18. [root@localhost ~]# systemctl restart httpd
    19. [root@localhost ~]# curl www.openlab.com
    20. 1111 //这里是结果
    21. [root@localhost ~]#

    3.openlab下面的三个子页面创建及其配置文件的配置和加密

    3.1在刚刚的文件底下创建三个文件并且写入内容

    1. [root@localhost ~]# mkdir /var/www/openlab/student
    2. [root@localhost ~]# mkdir /var/www/openlab/data
    3. [root@localhost ~]# mkdir /var/www/openlab/money
    4. [root@localhost ~]# echo 1 > /var/www/openlab/student/index.html
    5. [root@localhost ~]# echo 2 >/var/www/openlab/data/index.html
    6. [root@localhost ~]# echo 3 >/var/www/openlab/money/index.html

    3.2创建两个用户并且在配置文件中加入用户内容

    创建song和tian用户密码都设置成redhat

    1. [root@localhost ~]# htpasswd -c /etc/httpd/yonghu song
    2. New password:
    3. Re-type new password:
    4. Adding password for user song
    5. [root@localhost ~]# htpasswd -c /etc/httpd/yonghu tian
    6. New password:
    7. Re-type new password:
    8. Adding password for user tian
    1. [root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf
    2. [root@localhost ~]# cat /etc/httpd/conf.d/vhost.conf
    3. <VirtualHost 192.168.171.129:80>
    4. Servername www.openlab.com
    5. DocumentRoot /var/www/openlab
    6. </VirtualHost>
    7. <Directory /var/www/openlab>
    8. AllowOverride none
    9. Require all granted
    10. </Directory>
    11. <directory /var/www/openlab/student>
    12. allowoverride none
    13. authtype basic
    14. authname "please login"
    15. authuserfile /etc/httpd/yonghu
    16. require user song tian
    17. </directory>
    1. [root@localhost ~]# curl www.openlab.com/student/ -u tian
    2. Enter host password for user 'tian':
    3. 1 //这里的运行结果
    4. [root@localhost ~]#

    3.3 加密

    1. [root@localhost ~]# yum install mod_ssl //这里需要下载一个mod_ssl
    2. [root@server ~]# cd /etc/pki/tls/private/
    3. [root@server private]# openssl genrsa -aes128 2048 > jiami.key
    4. [root@localhost certs]# cd /etc/pki/tls/certs/
    5. [root@localhost certs]# openssl req -utf8 -new -key /etc/pki/tls/private/jiami.key -x509 -days 365 -out jiami.crt

  • 相关阅读:
    LinkedList源码分析
    等保2.0二级内容
    淘宝/天猫API:item_sku-获取sku详细信息
    vue form设置rules不生效
    vue2+three.js实现宇宙(进阶版)
    Excel 插入和提取超链接
    面试的一些问题关于k8s中,镜像自动化脚本
    0开篇-介绍
    PyTorch入门之【tensor】
    六种最常见的软件供应链攻击
  • 原文地址:https://blog.csdn.net/m0_52326740/article/details/134482863