• 给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

  • 相关阅读:
    2022-07-20 Android 11 SELinux avc 修改sys目录下面某个节点的权限
    MultiPlayerShoot----C++学习记录02人物
    ELK 集群部署
    C#程序全局异常处理—WPF和Web API两种模式
    JVM coredump
    二叉树 | 层序遍历 | leecode刷题笔记
    一种新型侧信道攻击方法,影响大部分苹果 A&M 系列芯片
    基于用户行为的交易反欺诈探索
    阿里云全站加速 DCDN 重磅发布!打造新一代加速引擎
    java计算机毕业设计基于ssm的社区失物招领+房屋租赁+停车+宠物互助平台
  • 原文地址:https://blog.csdn.net/m0_52326740/article/details/134482863