1、安装snap环境
1.1 确认自己的centos版本
cat /etc/centos-release
1.2 确认版本进行安装
centos7
sudo yum install epel-release
centos8
sudo dnf install epel-release
sudo dnf upgrade
1.3 安装snap
sudo yum install snapd
1.4进行配置
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
2、更新snap
sudo snap install core
sudo snap refresh core
3、安装certbot并配置连接
sudo ln -s /snap/bin/certbot /usr/bin/certbot
4、生成证书
sudo certbot certonly --nginx
生成证书可能会出现找不到nginx的问题,执行
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
ln -s /usr/local/nginx/conf /etc/nginx
5、生成证书的过程
6、将生成privkey.pem转为privkey.key
openssl rsa -in privkey.pem -out privkey.key