当前位置:   article > 正文

LNMP下配置免费SSL安全证书(https)_lnmp certbot auto

lnmp certbot auto

本文作者:陈进坚
博客地址:https://jian1098.github.io
CSDN博客:https://blog.csdn.net/c_jian
联系方式:jian1098@qq.com
版权声明:文章仅在本人博客和CSDN博客中发布,所有文章未经授权禁止转载!

环境要求

  • LNMP
  • 域名

安装依赖

$ cd /root/
$ wget https://dl.eff.org/certbot-auto --no-check-certificate
$ chmod +x ./certbot-auto
$ ./certbot-auto -n
  • 1
  • 2
  • 3
  • 4

生成证书

注意将 www.vpser.net 替换成你的域名

单域名生成证书:

$ ./certbot-auto certonly --email youemail@vpser.net --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.vpser.net -d www.vpser.net
  • 1

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

$ ./certbot-auto certonly --email youemail@vpser.net --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.vpser.net -d www.vpser.net -d bbs.vpser.net
  • 1

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

$ ./certbot-auto certonly --email youemail@vpser.net --agree-tos --no-eff-email --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
  • 1

提示以下信息表示生成成功

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

生成的证书会存在:/etc/letsencrypt/live/www.vpser.net/ 目录下,检查是否有两个.pom的证书文件

修改配置

  • 下载配置文件并替换掉所有的www.example.net为你的域名,仅限单域名

链接:https://pan.baidu.com/s/1HC1ErFjtoDe8akzzWys29A 密码:i2fi

  • 上传至/usr/local/nginx/conf/vhost 并替换原来的文件

  • 执行:/etc/init.d/nginx reload 重新载入配置使其生效。

到这里你的域名应该就已经变成https了

证书续期

因为证书只有90天,所以建议使用crontab进行自动续期,间隔5天就可以了,不能太频繁:

$ crontab -e
0 3 */5 * * /root/certbot-auto renew --disable-hook-validation --renew-hook "/etc/init.d/nginx reload"
  • 1
  • 2

本文参考:https://www.vpser.net/build/letsencrypt-free-ssl.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/257626
推荐阅读
相关标签
  

闽ICP备14008679号