http作业

综合练习:请给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

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# yum install httpd -y
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
<Virtualhost 192.168.126.140:80>
        DocumentRoot /www/openlab
        Servername www.openlab.com
</Virtualhost>
<Directory /www>
        AllowOverride none
        Require all granted
</Directory>
[root@localhost ~]# mkdir /www/openlab -p
[root@localhost ~]# echo 'welcome to openlab!!!' > /www/openlab/index.html
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# vim /etc/hosts 
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.126.140 www.openlab.com
[root@localhost ~]# curl http://www.openlab.com
welcome to openlab!!!

网站需求2

------------------------------------------------------------------------------------------------------------------
#教学资料
[root@localhost ~]# mkdir /www/openlab/data
[root@localhost ~]# echo this is data > /www/openlab/data/index.html
#data后一定要加/,否则系统会将data当成一个网页文件,解析不了
#但在浏览器中可以不加
[root@localhost ~]# curl http://www.openlab.com/data/
this is data
------------------------------------------------------------------------------------------------------------------
#学生信息
[root@localhost ~]# mkdir /www/openlab/student
[root@localhost ~]# echo this is student > /www/openlab/student/index.html
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
<Virtualhost 192.168.126.140:80>
        DocumentRoot /www/openlab
        Servername www.openlab.com
</Virtualhost>
<Directory /www>
        AllowOverride none
        Require all granted
</Directory>
<Directory /www/openlab/student>
        AuthType Basic
        AuthName "Login...."
        AuthUserfile /etc/httpd/users
        Require user song tian
</Directory>
#创建用户song tian
[root@localhost ~]# htpasswd -c /etc/httpd/users song
New password: 
Re-type new password: 
Adding password for user song
[root@localhost ~]# htpasswd /etc/httpd/users tian
New password: 
Re-type new password: 
Adding password for user tian
#查看用户是否存在
[root@localhost ~]# cat /etc/httpd/users
song:$apr1$jmumSjZg$NQ/.Vwjd4Z2LQa3G8AA.g.
tian:$apr1$s0B0LyB/$dzg8iGYYrKIVqysi201TJ/
#对配置文件更改后需要重启服务
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# curl http://www.openlab.com/student/ -u song:123
this is student
------------------------------------------------------------------------------------------------------------------
#缴费网站
[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
<Virtualhost 192.168.126.140:80>
        DocumentRoot /www/openlab
        Servername www.openlab.com
</Virtualhost>
<Directory /www>
        AllowOverride none
        Require all granted
</Directory>
<Directory /www/openlab/student>
        AuthType Basic
        AuthName "Login...."
        AuthUserfile /etc/httpd/users
        Require user song tian
</Directory>
<Virtualhost 192.168.126.140:443>
        DocumentRoot /www/certs
        Servername www.openlab.com
        SSLEngine on
        SSLCertificateFile /certs/haha.crt
        SSLCertificateKeyFile /private/haha.key
</Virtualhost>
[root@localhost ~]# mkdir /www/certs
[root@localhost ~]# mkdir /www/certs/money
[root@localhost ~]# echo this is money > /www/certs/money/index.html
#安装加密模块ssl
[root@localhost ~]# yum install mod_ssl -y
#生成密钥
[root@localhost ~]# mkdir /certs
[root@localhost ~]# mkdir /private
[root@localhost ~]# openssl genrsa 2048 > /private/haha.key
[root@localhost ~]# openssl req -new -key /private/haha.key -x509 -days 365 -out /certs/haha.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) []:shaanxi
Locality Name (eg, city) [Default City]:xian
Organization Name (eg, company) [Default Company Ltd]:ce
Organizational Unit Name (eg, section) []:11
Common Name (eg, your name or your server's hostname) []:hostname
Email Address []:admin@admin.com
[root@localhost ~]# systemctl restart httpd
[root@localhost ~]# curl -k https://www.openlab.com/money/
this is money
#测试
[root@localhost ~]# curl -k http://www.openlab.com
welcome to openlab!!!
[root@localhost ~]# curl -k http://www.openlab.com/data/
this is data
[root@localhost ~]# curl -k http://www.openlab.com/student/ -u tian:123
this is student

相关推荐

  1. http作业

    2024-05-01 07:32:05       38 阅读
  2. HttpsHTTPS协议 的介绍及作用

    2024-05-01 07:32:05       49 阅读
  3. 作业..........

    2024-05-01 07:32:05       55 阅读
  4. Spring Cloud Feign作为HTTP客户端调用远程HTTP服务

    2024-05-01 07:32:05       62 阅读
  5. HTTP 协议在互联网中的作用是什么?

    2024-05-01 07:32:05       49 阅读
  6. HTTP协议中的Keep-Alive是什么作用

    2024-05-01 07:32:05       27 阅读
  7. <span style='color:red;'>HTTPS</span>

    HTTPS

    2024-05-01 07:32:05      60 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-01 07:32:05       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-01 07:32:05       101 阅读
  3. 在Django里面运行非项目文件

    2024-05-01 07:32:05       82 阅读
  4. Python语言-面向对象

    2024-05-01 07:32:05       91 阅读

热门阅读

  1. Ae 中 Range Selector 和 Expression Selector 有什么区别?

    2024-05-01 07:32:05       32 阅读
  2. 每天学习一个Linux命令之ldconfig

    2024-05-01 07:32:05       34 阅读
  3. Python学习指南

    2024-05-01 07:32:05       34 阅读
  4. redis运维篇上篇

    2024-05-01 07:32:05       118 阅读
  5. C++——数据结构stack,queue,priority_queue

    2024-05-01 07:32:05       34 阅读
  6. 语言模型:智能化未来的钥匙

    2024-05-01 07:32:05       24 阅读
  7. 在C++中初始化二维数组的几种不同方法

    2024-05-01 07:32:05       32 阅读
  8. Ubuntu22.04 私钥登录

    2024-05-01 07:32:05       104 阅读
  9. 常用网络知识点(网管网工需掌握)

    2024-05-01 07:32:05       26 阅读
  10. 关于chatgpt的理解与探索

    2024-05-01 07:32:05       31 阅读
  11. 移动端适配方案

    2024-05-01 07:32:05       35 阅读
  12. Go语言中的map使用及并发安全

    2024-05-01 07:32:05       42 阅读