在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
  • 20
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

acro_09

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值