1. 安装 acme.sh
安装很简单, 一个命令:
curl https://get.acme.sh | sh -s email=my@example.com
my@example.com邮箱改成你自己的邮箱
2.切换CA证书机构
acme.sh --set-default-ca --server Letsencrypt.org
Letsencrypt.org字段可以更换为acme.sh默认支持的CA或支持acme协议的链接
GitHub - acmesh-official/acme.sh: A pure Unix shell script implementing ACME client protocolGitHub - acmesh-official/acme.sh: A pure Unix shell script implementing ACME client protocolGitHub - acmesh-official/acme.sh: A pure Unix shell script implementing ACME client protocol
3.生成证书
acme.sh --issue -d domain.com --nginx /usr/local/nginx/conf/nginx.conf
注意nginx.conf listen 80端口下的server_name domain.com;是你要颁发证书的域名
证书地址:
[Tue Jul 2 10:22:13 AM CST 2024] Your cert is in: /root/.acme.sh/domain.com_ecc/domain.com.cer
[Tue Jul 2 10:22:13 AM CST 2024] Your cert key is in: /root/.acme.sh/domain.com_ecc/domain.key
[Tue Jul 2 10:22:13 AM CST 2024] The intermediate CA cert is in: /root/.acme.sh/domain.com_ecc/ca.cer
[Tue Jul 2 10:22:13 AM CST 2024] And the full chain certs is there: /root/.acme.sh/domain.com_ecc/fullchain.cer
证书配置到你的nginx上就可以