在python3環(huán)境安裝certbot:
pip3 install certbot certbot-nginx
在nginx正常運(yùn)行的情況下,以下自動(dòng)完成申請,需要替換 email@youremail.com , domain.com 以及 -d 后面的域名為自己的域名:
certbot --nginx --agree-tos --redirect \
-m email@youremail.com --eff-email \
--preferred-challenges http-01 \
--cert-name domain.com \
-d domain.com,xyz.domain.com,www.domain.com -q
申請完成后,默認(rèn)分配文件到 /etc/letsencrypt 中,并且自動(dòng)修改 /etc/nginx/conf.d/ 中的nginx配置文件 。
以下幾個(gè)常用命令。
擴(kuò)展域名:
certbot --nginx --agree-tos -w /etc/letsencrypt --expand \
-d taskimage.com,www.taskimage.com,advice.domain.com,image.domain.com
為nginx生成配置文件:
certbot --nginx install --cert-path /etc/letsencrypt/live/domain.com/ \
--key-path /etc/letsencrypt/live/domain.com/privkey.pem \
--fullchain-path /etc/letsencrypt/live/domain.com/fullchain.pem \
-d domain.com,advice.domain.com,image.domain.com
簡單申請新的證書:
certbot --nginx
會(huì)要求填寫一系列信息。
只申請證書,不修改配置:
certbot --nginx certonly