在Apache HTTP服务器上配置 TLS加密

  1. 安装mod_ssl软件包
[root@localhost conf.d]# dnf install mod_ssl -y

此时查看监听端口多了一个443端口
在这里插入图片描述

  1. 自己构造证书
[root@localhost conf.d]# cd /etc/pki/tls/certs/
[root@localhost certs]# openssl genrsa > jiami.key
[root@localhost certs]# openssl req -utf8 -new -key jiami.key -x509 -days 100 -out jiami.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) []:shaaxi
Locality Name (eg, city) [Default City]:xi'an
Organization Name (eg, company) [Default Company Ltd]:rhce
Organizational Unit Name (eg, section) []:peihua
Common Name (eg, your name or your server's hostname) []:www.hehe.com
Email Address []:admin@hehe.com
[root@localhost certs]# mv jiami.key ../private/
[root@localhost certs]# cd -
/etc/httpd/conf.d
[root@localhost conf.d]# ll
total 32
-rw-r--r--. 1 root root 2916 Jul 20  2023 autoindex.conf
-rw-r--r--. 1 root root  400 Jul 20  2023 README
-rw-r--r--. 1 root root 8720 Jul 20  2023 ssl.conf
-rw-r--r--. 1 root root 1252 Jul 20  2023 userdir.conf
-rw-r--r--. 1 root root 1171 Jul  5 15:41 vhost.conf
-rw-r--r--. 1 root root  653 Jul 20  2023 welcome.conf

修改配置文件

[root@localhost conf.d]# vim ssl.conf 

在这里插入图片描述
重启服务

[root@localhost conf.d]# systemctl restart httpd

测试
在这里插入图片描述

  1. 在vhost.conf配置文件中添加信息

在这里插入图片描述

  1. 测试
    之前在/www/hehe/index.html里写的东西现在还都能访问,证书也构造成功。
    在这里插入图片描述在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在本地访问需要在本地解析文件中添加www.hehe.com主机名

[root@localhost conf.d]# vim /etc/hosts

在这里插入图片描述

[root@localhost conf.d]# curl -k https://www.hehe.com
welcome to hehe

相关推荐

  1. 如何使用Gunicorn配置SSL/TLS加密Web服务

    2024-07-12 00:02:03       36 阅读
  2. 如何虚拟专用服务器配置 Nginx Web 服务器

    2024-07-12 00:02:03       34 阅读
  3. Beats:单个服务器配置多个 Beats 实例

    2024-07-12 00:02:03       40 阅读
  4. Ubuntu 配置 Nginx 作为 Web 服务器

    2024-07-12 00:02:03       54 阅读
  5. 如何海外服务器配置静态路由?

    2024-07-12 00:02:03       38 阅读
  6. 如何 Mac 配置一个本地 Web 服务器

    2024-07-12 00:02:03       25 阅读

最近更新

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

    2024-07-12 00:02:03       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-12 00:02:03       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-12 00:02:03       58 阅读
  4. Python语言-面向对象

    2024-07-12 00:02:03       69 阅读

热门阅读

  1. 贪心算法-以高校科研管理系统为例

    2024-07-12 00:02:03       23 阅读
  2. ActivityThread与AMS之间关系是什么?

    2024-07-12 00:02:03       21 阅读
  3. 【学习笔记】Redis学习笔记——第7章 压缩列表

    2024-07-12 00:02:03       22 阅读
  4. Mysql中常用函数的使用示例

    2024-07-12 00:02:03       21 阅读
  5. IP地址笔记

    2024-07-12 00:02:03       18 阅读
  6. Grind 75 | 3. merge two sorted lists

    2024-07-12 00:02:03       24 阅读
  7. 6、Redis系统-数据结构-07-QuickList

    2024-07-12 00:02:03       23 阅读
  8. flink使用

    2024-07-12 00:02:03       23 阅读
  9. Github 2024-07-05开源项目日报 Top10

    2024-07-12 00:02:03       20 阅读
  10. 2024.7.7刷题记录

    2024-07-12 00:02:03       21 阅读