Loading... # 1.安装acme.sh 建议切换到root模式,可以减少证书安装时的问题 `sudo su` 注意:MacOS 不用切换到root更简单。 ```bash curl https://get.acme.sh | sh -s email=my@example.com ``` 如果上面官方下载地址失败 或者 太慢,可以选用国内的备用地址 ```bash curl https://gitcode.net/cert/cn-acme.sh/-/raw/master/install.sh?inline=false | sh -s email=my@example.com ``` 注意:安装完成后,再重新打开命令行(如果是 SSH,选择重新连接),以使acme.sh命令生效。 # 2.对域名进行授权 这里选择使用域名解析商提供的 api 自动添加 txt 记录完成验证 **acme.sh** 目前支持 cloudflare, dnspod, cloudxns, godaddy 以及 ovh 等数十种解析商的自动集成. 以 dnspod 为例, 你需要先登录到 dnspod 账号, 生成你的 api id 和 api key, 都是免费的. 然后: ```bash export DP_Id="1234" export DP_Key="sADDsdasdgdsf" ``` # 3.证书申请 & 部署 #### Apache example: ```bash acme.sh --install-cert --issue --dns dns_dp -d example.com \ --cert-file /path/to/certfile/in/apache/cert.pem \ --key-file /path/to/keyfile/in/apache/key.pem \ --fullchain-file /path/to/fullchain/certfile/apache/fullchain.pem \ --reloadcmd "service apache2 force-reload" ``` #### Nginx example: ```bash acme.sh --install-cert --issue --dns dns_dp -d example.com \ --key-file /path/to/keyfile/in/nginx/key.pem \ --fullchain-file /path/to/fullchain/nginx/cert.pem \ --reloadcmd "service nginx force-reload" ``` 大功告成,宝塔面板重新添加一下域名即可! 证书进入到30天有效期,acme.sh 会自动完成续期。 最后修改:2022 年 10 月 26 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 4 如果觉得我的文章对你有用,请随意赞赏