首页 > 代码

acme.sh安装与自动签发 Let’s Encrypt SSL 步骤

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


  • 免费申请cloudflare域名SSL证书时,边源端证书和客户端证书及源服务器证书区别
  • 一、你的目标: 你只需要一个 长期有效 的 SSL 证书,部署在你宝塔面板的网站上,让 Nginx/Apach […]

  • 彻底删除wordpress里的global-styles-inline-css
  • <style id='global-styles-inline-css' type= […]

  • 能批量下载 X(Twitter)公开视频的 Python 版
  • 能批量下载 X(Twitter)公开视频的 Python 版。核心用的是 yt-dlp,它是一个活跃维护的开源 […]

  • 服务器上mysql数据库很多,某个库把整台服务器拉爆了,如何定位找到罪魁?
  • 服务器上mysql数据库很多,某个数据库把整台服务器拉爆了,如何定位找到罪魁? 先在 MySQL 里把“正在烧 […]

  • 极速打包几百万文件成.zip,比传统方式快几十倍
  • 假如,一个文件夹里面有几十上百万张图片,要把这个文件夹打包成.zip,按传统的windows自带的工具压缩或普 […]

  • Rufus是什么?为什么很多人推荐
  • Rufus 是一个非常流行的Windows 平台下用于创建启动U盘(Bootable USB)的免费工具。官网 […]