acme.sh 实现了 acme
协议, 可以从 letsencrypt 生成免费的证书.
1. 安装 acme.sh
1 2 3 4 5 6 7 8 9 10
| # sh 安装 curl https://get.acme.sh | sh
# 源码安装 git clone https://github.com/acmesh-official/acme.sh.git cd ./acme.sh ./acme.sh --install
# 创建 一个 bash 的 alias alias acme.sh=~/.acme.sh/acme.sh
|
2. 生成证书
在生成之前,确保你的域名可以正常访问到webroot目录下
1
| acme.sh --issue -d www.zhiqiang.wang --webroot /wwwroot/zhiqiang.wang/
|
3. copy/安装 证书
1 2 3 4 5 6
| mkdir -p /etc/nginx/ssl
acme.sh --installcert -d www.zhiqiang.wang \ --key-file /etc/nginx/ssl/www.zhiqiang.wang.key \ --fullchain-file /etc/nginx/ssl/www.zhiqiang.wang.cer \ --reloadcmd "service nginx force-reload"
|
4. 更新证书
目前证书在 60 天以后会自动更新, 你无需任何操作. 今后有可能会缩短这个时间, 不过都是自动的, 你不用关心.
详细文档
https://github.com/acmesh-official/acme.sh/wiki