2. RHEL8 + Nginx + Node.js + PM2部署SYSIDC
一、
二、
八、创建一个定期自动续签 Let’s Encrypt 证书的脚本,并使用 cron 任务定期执
cron 任务定期执(1)自动续签脚本
vim /root/renew_ssl.sh#!/bin/bash
# 定义域名
DOMAINS="-d sysidc.com -d www.sysidc.com"
# 运行 Certbot 续签命令
certbot renew --nginx --quiet --post-hook "systemctl reload nginx"
# 检查证书是否即将过期(30天内)
if certbot certificates | grep -q "VALID:.* days"; then
echo "SSL 证书仍然有效,无需更新"
else
echo "尝试更新 SSL 证书..."
certbot certonly --nginx $DOMAINS --non-interactive --agree-tos --email admin@sysidc.com
systemctl reload nginx
echo "SSL 证书更新完成,并已重新加载 Nginx"
fi
(2)赋予执行权限
(3)配置 cron 自动执行
cron 自动执行(4)手动测试
最后更新于