在Linux上安装let's encrypt的最简单方法
时间:2020-02-23 14:38:04 来源:igfitidea点击:
在Linux上安装Let's encrypt:今天,我想向我们展示在Linux上安装Letsencrypt的最简单,最快的方法。该过程涉及几个步骤,实际上是自动化的。目的是使用EFF的certbot引导脚本,从Lets Encrypt请求的SSL证书。
Certbot是一个易于使用的客户端,可从Lets Encrypt(由EFF,Mozilla和其他启动的开放式证书颁发机构)获取证书并将其部署到Web服务器。
以下是要遵循的步骤:
下载certbot-auto脚本
wget https://dl.eff.org/certbot-auto -P /usr/local/bin
使脚本可执行:
chmod a+x /usr/local/bin/certbot-auto
在可以请求ssl证书之前,请打开防火墙上的端口443. 本演示假定我们正在运行防火墙系统为Firewalld的CentOS7.x。如果我们有其他系统,例如Ubuntu或者Debian,防火墙系统可能会有所不同。
firewall-cmd --add-service https --permanent firewall-cmd --reload
现在请求ssl证书:
certbot-auto certonly -d mydomain.com -d www.mydomain.com
在我们发出第一个请求时,该脚本将安装所需的软件包/依赖项并设置虚拟环境。
请注意,我们需要指定域的活动dns A记录。对于www.mydomain.com,这可以是CNAME记录。
在提示符下回答几个问题,我们将立即获得ssl证书和私钥。缺省位置是:/etc/letsencrypt/live
续订证书
certbot-auto --renew
使用挂机前和挂机后自动续订
- For nginx # /usr/local/bin/certbot-auto renew --pre-hook "service nginx stop" \ --post-hook "service nginx start" - For apache # /usr/local/bin/certbot-auto renew --pre-hook "systemctl stop apache2" \ --post-hook "systemctl start apache2"
强制进行手动更新:
certbot renew --force-renewal
如果我们想使用cron作业,则crontab的行应类似于以下内容:
15 3 * * * usr/local/bin/certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx start"