1、安装acme.sh
curl https://get.acme.sh | sh
2、获取 Let’s Encrypt 证书
acme.sh --issue --standalone -d example.com # example.com是你要申请证书的域名
如果报错acme.sh命令不存在,执行source ~/.bashrc命令试试
一般是acme.sh是安装在~目录下的.acme.sh文件夹中,可能会提示你没有安装socat,yum install socat真能装一下即可,如果不是root用户,则:
sudo ~/.acme.sh/acme.sh --issue --standalone -d example.com
运行成功后会提示你的证书在哪个目录下,我的是提示在root/.acme.sh/example.com/example.com.key
3、安装acme.sh证书
官方:
acme.sh --installcert -d www.jiangyong.org \
--key-file /etc/nginx/ssl/www.jiangyong.org.key \
--fullchain-file /etc/nginx/ssl/www.jiangyong.org.cer \
--reloadcmd "service nginx force-reload"
我的:
sudo ~/.acme.sh/acme.sh --installcert -d example.com \
--keypath /your/path/example.com.key \
--fullchainpath /your/path/example.com..cer
这里加不直接写
acme.sh,而写成sudo ~/.acme.sh/acme.sh是有原因的,因为我装的acme.sh不是root权限写装的,所以生成的证书就不在安装的按个目录,而是在root下的一个目录下,所以这样写才能将真正的证书安装到你所需要的目录。