针对Nginx环境
sudo apt update
#安装Python等依赖
sudo apt install python3 python3-dev python3-venv libaugeas-dev gcc
#安装Certbot
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-nginx
#设置certbot命令
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
#给网站安装认证
sudo certbot --nginx
#定期更新认证
echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
Leave a Reply