IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    免费SSL证书Let\'s Encrypt(certbot)安装使用教程

    VPS侦探发表于 2016-07-04 01:03:04
    love 0

    letsencrypt

    Let's Encrypt是很火的一个免费SSL证书发行项目,自动化发行证书,证书有90天的有效期。适合个人使用或者临时使用,不用再忍受自签发证书不受浏览器信赖的提示。去年VPS侦探曾经说过Let's Encrypt的使用教程,但是Let's Encrypt已经发布了新的工具certbot,虽然是新的工具,但是生成证书的使用方法和参数是基本一致的,证书续期更简单了。但是目前看certbot在一些老版本的Linux发行版上的兼容性还是有问题的,特别是在CentOS 5上因为python版本过低是无法用的,CentOS 6上需要先安装epel才行,当然也有很多第三方的工具你也可以自己去尝试一下。

    安装方法:

    如果是CentOS 6,先执行:yum install epel-release

    cd /root/
    wget https://dl.eff.org/certbot-auto --no-check-certificate
    chmod +x ./certbot-auto
    ./certbot-auto -n

    接下来就会自动安装所需的依赖包。

    单域名生成证书:

    ./certbot-auto certonly --email admin@vpser.net --agree-tos --webroot -w /home/wwwroot/www.vpser.net -d www.vpser.net

    多域名单目录生成单证书:(即一个网站多个域名使用同一个证书)

    ./certbot-auto certonly --email admin@vpser.net --agree-tos --webroot -w /home/wwwroot/www.vpser.net -d www.vpser.net -d bbs.vpser.net

    多域名多目录生成多个证书:(即一次生成多个域名的多个证书)

    ./certbot-auto certonly --email admin@vpser.net --agree-tos --webroot -w /home/wwwroot/www.vpser.net -d www.vpser.net -d bbs.vpser.net -w /home/wwwroot/lnmp.org -d www.lnmp.org -d lnmp.org

    提示

    IMPORTANT NOTES:
    - Congratulations! Your certificate and chain have been saved at
    /etc/letsencrypt/live/www.vpser.net/fullchain.pem. Your cert will
    expire on 2016-10-01. To obtain a new or tweaked version of this
    certificate in the future, simply run certbot-auto again. To
    non-interactively renew *all* of your certificates, run
    "certbot-auto renew"
    - If you like Certbot, please consider supporting our work by:

    Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
    Donating to EFF: https://eff.org/donate-le

    就是生成成功。

    生成的证书会存在:/etc/letsencrypt/live/www.vpser.net/ 目录下

    具体Nginx和Apache的配置可以参考:http://www.vpser.net/build/letsencrypt-free-ssl.html 里的配置文件。

    证书续期

    cerrbot的续期比原来的更加简单,因为证书只有90天,所以建议使用crontab进行自动续期:

    crontab 里加上如下规则:0 3 */5 * * /root/certbot-auto renew 这样每5天就会执行一次续期操作。当然时间也可以自行进行调整,建议别太频繁,因为他们都有请求次数的限制。

    注意事项:

    1、因为默认LNMP的虚拟主机里是禁止 . 开头的隐藏文件及目录的,所以访问http://abc.com/.well-known/acme-challenge/**** 这个链接的话返回403错误,所以必须要将对应虚拟主机配置文件里的
    location ~ /\.
    {
    deny all;
    }
    这段配置删掉或注释掉或在这段配置前面加上
    location ~ /.well-known {
    allow all;
    }

    以上配置代码,然后重启nginx。

    2、如果要启用http2的话,建议编辑lnmp.conf,将里面的Nginx_Modules_Options的单引号里加上 --with-openssl=/root/openssl-1.0.2h

    并执行: cd /root && wget -c https://www.openssl.org/source/openssl-1.0.2h.tar.gz && tar zxf openssl-1.0.2h.tar.gz ,然后使用升级脚本 ./upgrade.sh nginx 升级nginx至1.9.5或更高版本。

    有问题可以在本帖或VPS侦探论坛提问。

    VPS侦探论坛邀请码:http://bbs.vpser.net/reg.php?invitecode=41f1ca437cCC9FXe 有效期至:2016-7-8 13:07

    相关文章:

    • 免费SSL安全证书Let’s Encrypt安装使用教程(附Nginx/Apache配置)
    • 在LNMP或Nginx上配置NameCheap免费SSL
    • NameCheap 2010年5月优惠码
    • LNMP一键安装包 自动无缝升级Nginx至任意版本
    • VPS初始化及Nginx+MySQL+PHP/PHPMyAdmin安装优化

    © VPS侦探 for VPS侦探, 2016. | Permalink | No comment | Add to del.icio.us
    Post tags: Apache SSL, certbot, http2, Let's Encrypt, letsencrypt, letsencrypt教程, Nginx SSL, SSL证书, SSL配置, 免费SSL, 免费SSL证书

    美国VPS推荐 | 军哥代购 - 提供美国及海外VPS/VPN/域名代购,美元/欧元代付 QQ:503228080



沪ICP备19023445号-2号
友情链接