本文共 1522 字,大约阅读时间需要 5 分钟。
$ cd /root$ wget https://github.com/certbot/certbot/archive/master.zip $ unzip master.zip$ cd certbot-master/# 查看帮助$ ./certbot-auto --help
# 例子: $ ./certbot-auto certonly --standalone --agree-tos -v -t --email bell.zhouxiaobing@staginfo.com -d siot.staginfo.com# 例子: $ ./certbot-auto certonly --webroot -w /usr/local/nginx/html --email bell.zhouxiaobing@staginfo.com -d siot.staginfo.com# --webroot -w 后面路径是apache或nginx的静态部署的根路径文件夹# --standalone 会启动内置的webserver, 同时80端口不能够被占用,不然会报错:Problem binding to port 80: Could not bind to IPv4 or IPv6# (将邮箱地址和服务器域名替换)$ ./certbot-auto certonly --webroot -w /usr/local/nginx/html \ --email\ -d <域名>域名>
# 例子: cd /etc/letsencrypt/live/siot.staginfo.com$ ls /etc/letsencrypt/live/ <域名> # 文件夹下的文件:cert.pem chain.pem fullchain.pem privkey.pem README 域名>
# --no-self-upgrade 不更新certbot# --force-renew 强制更新证书 $ ./certbot-auto renew
$ cd /root$ vi ssl_auto_auth.sh
#/bin/sh datetime=`date '+%Y-%m-%d %H:%M:%S'`;echo "[$datetime] [certbot-auto renew]"# ps: 注意检查certbot-master的路径是否正确/root/certbot-master/certbot-auto renew --no-self-upgradeecho "[$datetime] [nginx restart]"# ps: 注意检查nginx的路径是否正确/usr/local/nginx/sbin/nginx -s reloadecho "[$datetime] [ok]"echo "=============end================"
$ crontab -e# 每月1号凌晨2点执行# ps: 注意脚本的路径是否一致0 2 1 * * /root/ssl_auto_auth.sh >>ssl_auto_auth.log 2>&1# 1分钟运行一次测试*/1 * * * * /root/ssl_auto_auth.sh >>ssl_auto_auth.log 2>&1
转载地址:http://oiyvb.baihongyu.com/