1. 环境准备
- 服务器
- 域名
- 官网地址
2. ssh登录服务器
升级下(可选)
sudo dnf update -y
- 安装nginx
#安装
sudo dnf install nginx -y
#开机启动项
sudo systemctl enable nginx
# 防火墙配置
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
# 其端口开发
firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo systemctl start nginx #启动nginx
sudo systemctl restart nginx
sudo systemctl status nginx #查看nginx
- 安装snap
默认不能直接装得先装下面的
sudo dnf install epel-release
sudo dnf upgrade
sudo dnf install snapd -y
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
snap install core
snap refresh core
如果报错:error: too early for operation, device not yet seeded or device model not acknowledged 就等下再执行
- 安装certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
- 下载个泛域名申请证书的脚本地址 根据readme 修改域名对应服务商的key token 把文件上传到服务器 修改文件权限:
chmod +x au.sh
运行下面的命令,域名和路径需要改成自己的
certbot certonly -d *.oursmart.cn --manual --preferred-challenges dns --manual-auth-hook "/opt/certbot/au.sh python aly add" --manual-cleanup-hook "/opt/certbot/au.sh python aly clean"
可能要输入邮箱(c可以取消),然后一路同意就好了 等待完成后进入/etc/letsencrypt/live/目录查看是否有对应域名的文件夹,有就已经申请成功,需要注意的是只针对泛域名生效,oursmart.cn无效
- 附带单个证书自动生成命令
sudo certbot --nginx