CertBot自动更新Nginx证书

安装certbot

centos7安装

环境准备

yum install epel-release  #安装依赖
yum install snapd         #安装snapd
#安装完成后,启动管理主要snapd通信套接字的systemd单元
stemctl enable --now snapd.socket
#创建软链接
ln -s /var/lib/snapd/snap /snap	

certbot安装

snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot

centos8安装

环境准备

#添加EPEL Repo
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled PowerTools

安装Certbot

Certbot 是以 RPM 包的形式提供给 CentOS 8 系统安装的,你可以从 EPEL 仓库中安装它。你可以从EPEL资源库中安装它,你已经在你的系统中启用了它。

sudo dnf install certbot python3-certbot-nginx

申请证书

获取并安装证书

说明:会自动安装证书并对/etc/nginx/nginx.conf中的证书进行替换

certbot --nginx

输入邮箱,同意协议,第二个接收广告信息的邮件询问可以拒绝

只获取证书

certbot certonly --nginx

自定义证书路径

certbot --nginx --nginx-server-root=/usr/local/nginx/conf

更新证书

所有由Let's encrypt care签发的证书有效期只有3个月。它允许你在证书到期前30天或更短的时间内更新证书。Certbot工具允许你通过单一命令行更新SSL。你也可以在一个cronjob中安排。
运行下面的命令来更新该系统上的所有证书。

sudo certbot renew

你也可以在没有实际更新证书的情况下进行一次模拟运行。通过这个方法,你可以验证SSL续费是否能通过cronjob来完成。

sudo certbot renew --dry-run

查看证书到期时间

sudo certbot certificates
posted @   &UnstopPable  阅读(35)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
点击右上角即可分享
微信分享提示