使用CertBot自动更新Nginx的ssl证书

1.安装snapd

1.1.添加EPEL

在CentOS 7系统中添加EPEL仓库

sudo yum install epel-release

1.2.安装snapd

使用仓库,安装snapd包

sudo yum install snapd

安装完成后,启动管理主要snapd通信套接字的systemd单元

sudo systemctl enable --now snapd.socket

创建软链接

sudo ln -s /var/lib/snapd/snap /snap

2.删除已存在的certbot

1
2
3
sudo apt-get remove certbot
sudo dnf remove certbot
sudo yum remove certbot

3.安装certbot

sudo snap install --classic certbot

3.1.创建软链接

sudo ln -s /snap/bin/certbot /usr/bin/certbot

3.2.运行CertBot

3.2.1.获取并安装证书

sudo certbot --nginx

3.2.2.只获取证书

sudo certbot certonly --nginx

4.测试自动更新

CertBot自带定时器,可以在证书过期钱自动更新证书,不需要再次运行CertBot,除非更改过配置。

以下命令可以测试证书的自动续订:

sudo certbot renew --dry-run
Congratulations, all simulated renewals succeeded:
  /etc/letsencrypt/live/createverse.fun/fullchain.pem (success)

常见问题

1.提示 nginx.conf 文件找不到

nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed

解决方法:

使用自定义路径

sudo certbot --nginx --nginx-server-root=/usr/local/nginx/conf
posted @   pyt123456  阅读(559)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示