Nginx + Certbot配置 HTTPS / SSL 证书(简化版已测试)

前提条件:

1.已有域名

2.Nginx 已安装并正在运行,且有对应的 Server 配置,在nginx.conf 中配置好80(http)

3.防火墙开放 80 和 443 端口

powershell 复制代码
#安装certbot
yum install certbot -y

#安装python-certbot-nginx
yum install python-certbot-nginx -y

#签发证书,替换你的域名yourdomain
certbot --nginx -d yourdomain

#检查 Certbot 版本
certbot --version	

重启nginx:

powershell 复制代码
systemctl restart nginx

测试 Certbot 自动续期:

powershell 复制代码
certbot renew --dry-run

真实续订(正式用):

powershell 复制代码
certbot renew

该命令会检查所有即将过期的证书,并尝试续订。注意:在使用完签发命令后,需重新nginx使站点ssl配置生效。

自动续订(计划任务用):

powershell 复制代码
#该命令可以将续订命令添加到crontab计划任务中,以实现自动续订,并重启nginx。
certbot renew --quiet --renew-hook 'sudo systemctl reload nginx'

#假设crontab计划任务会在每月1号执行1次续订命令,并在续订后重载Nginx配置,具体示例如下。
0 0 1 * * certbot renew --quiet --renew-hook 'sudo systemctl reload nginx' > /dev/null 2>&1
相关推荐
00后程序员张5 小时前
python 抓包在实际项目中的合理位置,结合代理抓包、设备侧抓包与数据流分析
android·ios·小程序·https·uni-app·iphone·webview
是娇娇公主~6 小时前
HTTPS【密钥交换+证书校验】流程讲解
网络·网络协议·面试·https·ssl
iru7 小时前
nginx被报CVE-2025-1695漏洞,检查后反馈是误报
运维·nginx
星哥说事11 小时前
SSL/TLS 证书管理,文件与数据库加密技术
数据库·网络协议·ssl
2501_9159184112 小时前
使用 HBuilder 上架 iOS 应用时常见的问题与应对方式
android·ios·小程序·https·uni-app·iphone·webview
2501_9160074714 小时前
iOS 崩溃日志的分析方法,将崩溃日志与运行过程结合分析
android·ios·小程序·https·uni-app·iphone·webview
RollingPin14 小时前
sudo gem install cocoapods 报错处理1
ssl·cocoapods·error·gem·安装失败
雪域迷影15 小时前
macOS系统上或首次使用Python的urllib模块时出现 ssl.SSLCertVerificationError 错误
python·macos·ssl
00后程序员张15 小时前
苹果应用商店上架App流程,签名证书、IPA 校验、上传
android·ios·小程序·https·uni-app·iphone·webview
2501_9160074715 小时前
iOS 上架需要哪些准备,围绕证书、描述文件和上传方式等关键环节展开分析
android·ios·小程序·https·uni-app·iphone·webview