已有python2的情况下安装python3,避免互相干扰:
sudo yum install python3 python3-pip
强制使用python3 (测试时不强制使用也没提示错误)
certbot --python /usr/bin/python3
在CentOS8上,使用dnf安装Certbot,但不安装python3-certbot-nginx, 这样 Certbot 不会自动修改 Nginx 配置:
sudo dnf install certbot -y
-------------生成证书--------------------
运行前需确保 80 端口未被占用(如 Nginx 需临时关闭)
每个域名单独生成证书安全些
sudo certbot certonly --standalone -d domain
Certificate is saved at: /etc/letsencrypt/live/domain/fullchain.pem
Key is saved at: /etc/letsencrypt/live/domain/privkey.pem
This certificate expires on xxxx-xx-xx.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
------------------------------------------------------------
-----------续订-----------------
运行前需确保 80 端口未被占用(如 Nginx 需临时关闭)
sudo certbot renew --dry-run # 测试续订
sudo certbot renew # 正式续订