acme.sh 是最流行的 Let’s Encrypt 客户端,支持:
不依赖 certbot(轻量无依赖)
支持自动续期(每 60 天自动更新)
支持 DNS 验证(可绕过 Cloudflare 缓存)
兼容 Nginx、Apache、Tomcat 等
1、安装 acme.sh(推荐 Gitee 源)
注意一次性复制到终端:
curl https://gitee.com/neilpang/acme.sh/raw/master/acme.sh -o ~/acme.sh && \
chmod +x ~/acme.sh && \
~/acme.sh --install --home ~/.acme.sh --accountemail lzw0796@gmail.com
2、接着运行下面两步(非常重要):
source ~/.bashrc
acme.sh --upgrade --auto-upgrade
3、验证是否安装成功
acme.sh --version
4、确认文件是否已经存在:
ls -l ~/.acme.sh/acme.sh
5、设置 DNS 环境变量(使用 Cloudflare API Token)
echo 'export CF_Token="UI2*************LK*****"' >> /etc/profile
source /etc/profile
这是Cloudflare API令牌:UI2*************LK*****
说明:为了防止每次 SSH 断开都要重新设置 Token,建议你添加到 /etc/profile
————————————
6、切换默认 CA 为 Let’s Encrypt(默认是 ZeroSSL)
acme.sh --set-default-ca --server letsencrypt
7、www.110xunren.com 单个样品(下面一次性复制到终端运行)
# 签发证书
acme.sh --issue --dns dns_cf -d 110xunren.com -d www.110xunren.com --ecc
# 安装证书
acme.sh --install-cert -d 110xunren.com --ecc \
--key-file /www/server/panel/vhost/cert/110xunren.com/privkey.pem \
--fullchain-file /www/server/panel/vhost/cert/110xunren.com/fullchain.pem \
--reloadcmd "nginx -t && nginx -s reload"
8、批处理:假如有如下域名:
————————————
guwen6.com
shilu8.com
shu23.com
shu25.com
shu27.com
shu29.com
wenxian8.com
xdongwu.com
51gushu.com
huahua98.com
xue97.com
congshu8.com
waimao6.com
seastarmarine.cn
seastar-marine.com
————————————
批量 SSL 脚本:把文件夹内的“batch_ssl_样品.sh”保存为 /root/batch_ssl.sh
注意改掉里面的域名为自己的。
在终端处设置这个文件权限:
chmod +x /root/batch_ssl.sh
运行:
bash /root/batch_ssl.sh