开心数据

人生天地间,忽如远行客。

0%

获取网站免费ssl证书

免费的ssl证书啊,很多网站在用。

参考:

https://github.com/acmesh-official/acme.sh

安装 acme.sh:

1
2
curl https://get.acme.sh | sh -s [email protected]
source ~/.bashrc

生成证书:

1
acme.sh --issue -d yourdomain.com --webroot /网站在服务器上的绝对路径

安装证书:

1
2
3
4
5
acme.sh --install-cert -d yourdomain.com \
--key-file /new/path/to/xxx.key \
--fullchain-file /new/path/to/fullchain.cer \
--ca-file /new/path/to/ca.cer \
--reloadcmd "systemctl reload nginx"

–key-file 私钥文件路径
–fullchain-file 全链证书路径
–ca-file CA证书路径
–reloadcmd 证书更新后执行的命令(如重启Nginx)

nginx配置:

1
2
3
ssl_certificate         /new/path/to/fullchain.cer;
ssl_certificate_key /new/path/to/xxx.key;
ssl_trusted_certificate /new/path/to/ca.cer;

自动续期:

acme.sh的cron任务(自动续期)会自动将新证书安装到上述指定的所有路径,无需手动干预。因此,只要初始安装命令正确,后续续期都会使用相同的路径。