申请网站https证书
申请前准备
服务器CentOS 7.9,公网可访问http//+域名
使用 Nginx 代理
一、安装 Certbot(Let’s Encrypt 客户端)
sudo yum install epel-release -y
sudo yum install certbot python2-certbot-nginx -y
二、安装并启动 Nginx
sudo yum install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx
检查是否运行:
sudo systemctl status nginx三、确保域名解析到你的服务器
请在你的域名服务商(如阿里云)中添加解析:
四、用 Certbot 自动申请 HTTPS 证书
执行命令(建议直接复制整行):
sudo certbot --nginx -d peijunlei.top -d blog.peijunlei.top
Certbot 会自动:
验证你的域名;
获取证书;
修改 Nginx 配置;
启用 HTTPS。
执行时会问:
输入邮箱(用来接收续期通知);
同意服务条款;
选择是否自动重定向到 HTTPS(建议选“2”)。
五、验证 HTTPS 是否生效
打开浏览器访问:
https://peijunlei.top
http://blog.peijunlei.top
出现 🔒 锁标志,就说明 HTTPS 成功启用了!
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果