Featured image of post 用Let's Encrypt申请免费的SSL证书,并自动续签

用Let's Encrypt申请免费的SSL证书,并自动续签

acme.sh 实现了 acme 协议, 可以从 let‘s encrypt 生成免费的证书

欢迎关注我的微信公众号【万能的小江江】

原项目地址:https://github.com/acmesh-official/acme.sh/

安装acme.sh

常用方法

1.curl

1
curl https://get.acme.sh | sh -s email=[email protected]

2.wget

1
wget -O -  https://get.acme.sh | sh -s email=[email protected]

3.git clone

1
2
3
git clone https://github.com/acmesh-official/acme.sh.git
cd acme.sh
./acme.sh --install -m  [email protected]

更多安装方法

How to install

用acme.sh获取证书

个人认为比较简单的一个方法

1
sudo ~/.acme.sh/acme.sh --issue -d your.domain.name --standalone -k ec-256

**注:**在使用这个方法之前需要先运行下面的指令关闭nginx(我平时习惯用nginx,其他框架的小伙伴可以自行上网搜其他暂停进程的方法)

关闭nginx

1
systemctl stop nginx

申请完之后开启nginx

1
systemctl start nginx

这个方法的原理

​ acme.sh假装自己是一个webserver,临时监听80端口,完成验证

更多高级使用方法

  1. [HTTPS之acme.sh申请证书](https://www.cnblogs.com/clsn/p/10040334.html)
  2. https://github.com/acmesh-official/acme.sh/wiki

需要注意的

​ 通过HTTP方式获取的证书每60天会自动更新一次,通过DNS方式获取的好像不会自动更新

​ 想要了解更多高级使用方法,请参见上节

(今天我迁移服务器重新部署证书,折腾这个折腾了一个下午,一直以为是nginx配置出现了问题)