第一步:申请一个阿里云的 DNS API 配置(Ali_Key 和 Ali_Secret),这个需要将其配置到acme的文件按里面。配置文件在:~/.acme.sh/account.conf中。
第二步: 创建证书存放目录。Nginx 证书存放目录是 /etc/nginx/ssl/yourweb.com/
第三步:获取证书。
acme.sh --issue --dns dns_ali -d yourweb.com -d "*.yourweb.com"或者
acme.sh --issue --dns dns_ali -d yourweb.com -d "*.yourweb.com" --keylength ec-256
命令解析:
--dns dns_ali:继续使用阿里云 DNS 验证方式(沿用你之前的配置)。注意如果市其他域名服务商要与之匹配
-d yourweb.com:包含主域名(建议加上,这样主域名也能用 HTTPS)。
-d "*.yourweb.com":这是通配符域名,覆盖所有子域名第四步:安装证书
如果是 RSA 证书:
bash
acme.sh --installcert -d yourweb.com -d "*.yourweb.com" \
--key-file /etc/nginx/ssl/yourweb.com/yourweb.com.key \
--fullchain-file /etc/nginx/ssl/yourweb.com/fullchain.cer
如果是 ECC 证书:
bash
acme.sh --installcert -d yourweb.com -d "*.yourweb.com" --ecc \
--key-file /etc/nginx/ssl/yourweb.com/yourweb.com.key \
--fullchain-file /etc/nginx/ssl/yourweb.com/fullchain.cer
第五步:重载 Nginx
注意修改网站的nginx配置文件将ssl证书指向以上目录,然后重载 Nginx 让新证书生效:
nginx -s reload
acme.sh会自动到期申请证书了。
不确定可以使用:acme.sh --list命令查看当前管理的域名证书有哪些。还有以下命令可以强制立刻申请一个证书:
acme.sh --renew -d example.com -d *.example.com --force
评论0
暂时没有评论