LNMP 一键包通过 acme 自动续期 SSL 免费证书失败的解决方法

搬瓦工

前几天发现一个挺久没有关注的网站居然 SSL 证书过期了,因为是使用的 LNMP 一键包,每次都是自动续期证书的,这么些年从来没遇到什么问题。于是就感觉很奇怪,登录上去看了看出错原因。然后发现是因为 acme.sh 更新了,改为使用 ZeroSSL 免费证书,而不是之前的 Let’s encrypt,所以就报错了,需要先注册一个 ZeroSSL 账户才行。本文分享一下 LNMP 一键包在使用 acme 自动续期 SSL 证书的时候失败的解决方法。

一、acme.sh 错误原因分析

为了复现错误,使用 lnmp ssl add 命令手动添加一下 SSL 证书试一下。下面是搬瓦工中文网站长记录的 LNMP 尝试手动添加 SSL 证书的报错信息。

root@BWH-CN2GIA-BETA:~# lnmp ssl add
+-------------------------------------------+
|    Manager for LNMP, Written by Licess    |
+-------------------------------------------+
|              https://lnmp.org             |
+-------------------------------------------+
Please enter domain(example: www.lnmp.org): banwagong.net
 Your domain: banwagong.net
Enter more domain name(example: lnmp.org *.lnmp.org): www.banwagong.net
 domain list: www.hostwindschina.com
Please enter the directory for domain banwagong.net: /home/wwwroot/banwagong.net
Allow Rewrite rule? (y/n) y
Please enter the rewrite of programme, 
wordpress,discuzx,typecho,thinkphp,laravel,codeigniter,yii2 rewrite was exist.
(Default rewrite: other): wordpress
You choose rewrite: wordpress
Allow access log? (y/n) y
Enter access log filename(Default:banwagong.net.log): 
You access log filename: banwagong.net.log
Enable PHP Pathinfo? (y/n) y
Enable pathinfo.
1: Use your own SSL Certificate and Key
2: Use Let's Encrypt to create SSL Certificate and Key
Enter 1 or 2: 2
It will be processed automatically.
/usr/local/acme.sh/acme.sh [found]
Removing exist domain certificate...
Starting create SSL Certificate use Let's Encrypt...
[Thu Jun  9 10:36:56 CST 2022] Using CA: https://acme.zerossl.com/v2/DV90
[Thu Jun  9 10:36:57 CST 2022] No EAB credentials found for ZeroSSL, let's get one
[Thu Jun  9 10:36:57 CST 2022] acme.sh is using ZeroSSL as default CA now.
[Thu Jun  9 10:36:57 CST 2022] Please update your account with an email address first.
[Thu Jun  9 10:36:57 CST 2022] acme.sh --register-account -m my@example.com
[Thu Jun  9 10:36:57 CST 2022] See: https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA
[Thu Jun  9 10:36:57 CST 2022] Please check log file for more details: /usr/local/acme.sh/acme.sh.log
Let's Encrypt SSL Certificate create failed!

可以看到,从上面的错误信息分析来看,主要是因为改用 ZeroSSL 之后,需要先注册一个账户,或者说需要先登记一个电子邮箱地址。所以解决问题的方法也很简单,我们按照提示先输入一个电子邮箱地址即可。

二、acme.sh 错误解决方法

如下所示,我们使用命令 acme.sh --register-account -m example@qq.com 添加一个电子邮件地址,将 example@qq.com 改成你自己的邮箱地址即可。

root@BWH-CN2GIA-BETA:~# acme.sh --register-account -m example@qq.com
[Thu Jun  9 10:37:39 CST 2022] No EAB credentials found for ZeroSSL, let's get one
[Thu Jun  9 10:37:40 CST 2022] Registering account: https://acme.zerossl.com/v2/DV90
[Thu Jun  9 10:37:52 CST 2022] Registered
[Thu Jun  9 10:37:53 CST 2022] ACCOUNT_THUMBPRINT='aaabbbccc'

然后就可以看到账户注册成功,之后我们重新使用 lnmp ssl add 命令给域名添加 SSL 证书即可,就不会再次报错了。

LNMP 教程:《搬瓦工建站教程:一键安装 LNMP V1.9 建站环境(NGINX+MySQL+PHP)

三、搬瓦工新手教程和优惠

1、搬瓦工新手入门

  1. 搬瓦工新手入门教程(1):搬瓦工众多方案怎么选择
  2. 搬瓦工新手入门教程(2):搬瓦工机房选择和速度测试
  3. 搬瓦工新手入门教程(3):注册账户和微信支付、支付宝购买教程
  4. 搬瓦工新手入门教程(4):登陆搬瓦工网站后台查看 VPS,登录 KiwiVM 面板进行简单管理
  5. 搬瓦工新手入门教程(5):通过 KiwiVM 后台面板更换操作系统并获取登陆信息

2、搬瓦工推荐方案

优惠码:BWHCCNCXVV(优惠力度 6.58%)

更多推荐:

方案内存CPU硬盘流量/月带宽机房价格购买
KVM
(最便宜)
1GB2核20GB1TB1GbpsDC3 CN2
DC8 ZNET
$49.99/年购买
KVM2GB3核40GB2TB1Gbps$52.99/半年
$99.99/年
购买
CN2GIA-E
(最推荐)
1GB2核20GB1TB2.5GbpsDC6 CN2 GIA-E
DC9 CN2 GIA
日本软银 JPOS_1
荷兰 EUNL_9
$49.99/季度
$169.99/年
购买
CN2GIA-E2GB3核40GB2TB2.5Gbps$89.99/季度
$299.99/年
购买
HK2GB2核40GB0.5TB1Gbps中国香港 CN2 GIA
日本东京 CN2 GIA
$89.99/月
$899.99/年
购买
HK4GB4核80GB1TB1Gbps$155.99/月
$1559.99/年
购买
OSAKA2GB2核40GB0.5TB1.5Gbps日本大阪 CN2 GIA$49.99/月
$499.99/年
购买
OSAKA4GB4核80GB1TB1.5Gbps$86.99/月
$869.99/年
购买

此外,也可以参考《2021年最新搬瓦工优惠码/搬瓦工便宜套餐/搬瓦工新手教程整理》。

3、搬瓦工补货通知

下面的优惠通知只会在有优惠活动的时候推送信息,其他时候都是禁言的,所以不会对大家造成打扰,可以放心关注。

未经允许不得转载:搬瓦工 » LNMP 一键包通过 acme 自动续期 SSL 免费证书失败的解决方法