官网:https://letsencrypt.org/

安装Let's Encrypt

安装非常简单直接克隆就可以了

  1. git clone https://github.com/letsencrypt/letsencrypt

生成通配符证书

期间需要根据提示设置DNS TXT记录,用作你对判断你是否拥有域名使用权

  1. cd letsencrypt
  2. ./certbot-auto certonly -d *.you.cn --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory

其中"you.cn"换成你的一级域名即可

参数 说明
certonly 表示安装模式,Certbot 有安装模式和验证模式两种类型的插件。
--manual 表示手动安装插件,Certbot 有很多插件,不同的插件都可以申请证书,用户可以根据需要自行选择
-d 为那些主机申请证书,如果是通配符,输入 *.you.cn(可以替换为你自己的一级域名)
--preferred-challenges dns 使用 DNS 方式校验域名所有权
--server Let's Encrypt ACME v2 版本使用的服务器不同于 v1 版本,需要显示指定。

接着可以看到下面界面结果:

  1. Dependency Installed:
  2. dwz.x86_64 :0.11-.el7 perl-srpm-macros.noarch :-.el7 tcl.x86_64 :8.5.-.el7 tix.x86_64 :8.4.-.el7 tk.x86_64 :8.5.-.el7 tkinter.x86_64 :2.7.-.el7_5
  3.  
  4. Complete!
  5. Creating virtual environment...
  6. Installing Python packages...
  7. Installation succeeded.
  8. Saving debug log to /var/log/letsencrypt/letsencrypt.log
  9. Plugins selected: Authenticator manual, Installer None
  10. Enter email address (used for urgent renewal and security notices) (Enter 'c' to
  11. cancel): @.com

接下来需要输入些指令

  1. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2. Please read the Terms of Service at
  3. https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
  4. agree in order to register with the ACME server at
  5. https://acme-v02.api.letsencrypt.org/directory
  6. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  7. (A)gree/(C)ancel: A
  8. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9. Would you be willing to share your email address with the Electronic Frontier
  10. Foundation, a founding partner of the Let's Encrypt project and the non-profit
  11. organization that develops Certbot? We'd like to send you email about our work
  12. encrypting the web, EFF news, campaigns, and ways to support digital freedom.
  13. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  14. (Y)es/(N)o: N
  15. Obtaining a new certificate
  16. Performing the following challenges:
  17. dns- challenge for kuaichuangkeji.com
  18.  
  19. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  20. NOTE: The IP of this machine will be publicly logged as having requested this
  21. certificate. If you're running certbot in manual mode on a machine that is not
  22. your server, please ensure you're okay with that.
  23.  
  24. Are you OK with your IP being logged?
  25. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  26. (Y)es/(N)o: Y

这里有几个需交互的提示

  • 是否同意 Let's Encrypt 协议要求=>需要同意
  • 是否分享你的邮箱
  • 询问是否对域名和机器(IP)进行绑定=>需要同意

需要注意的地方:

  1. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2. Please deploy a DNS TXT record under the name
  3. _acme-challenge.you.cn with the following value:
  4.  
  5. RYtObhDvEcXewZckknNQkBKIkvwIlbb4PNRel74LNwU
  6.  
  7. Before continuing, verify the record is deployed.
  8. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9. Press Enter to Continue
  10. Waiting for verification...
  11. Cleaning up challenges

要求配置 DNS TXT 记录,从而校验域名所有权,也就是判断证书申请者是否有域名的所有权。

上面输出要求给 _acme-challenge.you.cn 配置一条 TXT 记录,在没有确认 TXT 记录生效之前不要回车执行。

我用的是阿里云的域名服务器,控制台具体操作如下图所示:

 
服务器域名dns配置

确认生效后,回车执行,输出如下

  1. IMPORTANT NOTES:
  2. - Congratulations! Your certificate and chain have been saved at:
  3. /etc/letsencrypt/live/you.cn/fullchain.pem
  4. Your key file has been saved at:
  5. /etc/letsencrypt/live/you.cn/privkey.pem
  6. Your cert will expire on --. To obtain a new or tweaked
  7. version of this certificate in the future, simply run certbot-auto
  8. again. To non-interactively renew *all* of your certificates, run
  9. "certbot-auto renew"
  10. - If you like Certbot, please consider supporting our work by:
  11.  
  12. Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
  13. Donating to EFF: https://eff.org/donate-le

看到这个界面内容的话,恭喜你,证书安装成功了。

证书续签

注:证书在到期前30天才会续签成功,但为了确保证书在运行过程中不过期,官方建议每天自动执行续签两次;
使用crontab自动续期

  1. crontab -e // 编辑定时任务
  2. */ * * * certbot renew --quiet --renew-hook "/etc/init.d/nginx reload"
  • 需要注意"/etc/init.d/nginx reload"为nginx重启命令,需要根据自己服务器的重启命令重启即可;这里建议使用reload,不推荐使用restart,因为这样万一配错了,也不会影响服务器其他项目的运行

证书保存的路径[配置nginx需要用到的]

  1. /etc/letsencrypt/live/you.cn/fullchain.pem
  2. /etc/letsencrypt/live/you.cn/privkey.pem

nginx 开启 https

证书生成完成后可以到 /etc/letsencrypt/live/ 目录下查看对应域名的证书文件。编辑 nginx 配置文件监听 443 端口,启用 SSL,并配置 SSL 的公钥、私钥证书路径:

  1. server {
  2. listen ssl;
  3. server_name you.cn;
  4. root /home/www/you;
  5. index index.html index.htm index.php;
  6.  
  7. ssl on;
  8. ssl_certificate /etc/letsencrypt/live/you.cn/fullchain.pem;
  9. ssl_certificate_key /etc/letsencrypt/live/you.cn/privkey.pem;
  10. ...
  11. }

添加 HTTP 自动跳转到 HTTPS:

  1. server {
  2. listen ;
  3. server_name you.cn;
  4. location / {
  5. rewrite ^(.*)$ https://$host$1 permanent;
  6. }
  7. }
配置好nginx后,重启nginx
证书安装成功后,该域名下的所有二级域名都可以使用噢

取消证书

可以使用一下命令取消刚刚生成的密匙,也就是以上的反操作:

  1. certbot revoke --cert-path /etc/letsencrypt/live/you.cn/cert.pem
  2. certbot delete --cert-name you.cn

链接:https://www.jianshu.com/p/0d455c7a9326
来源:简书

Let's Encrypt 安装配置教程,免费的 SSL 证书的更多相关文章

  1. Let's Encrypt:初次使用免费的ssl证书,并生成java用的 jks(keystore) 文件

    现在都流行 https,今天晚上花了二个小时,学习了一下,这里做个学习总结: 因为刚开始接触,就使用免费的:Let's Encrypt Let's Encrypt证书特点: 1. 现在主流的浏览器(c ...

  2. Let's Encrypt 免费通配符 SSL 证书申请教程——但是也需要email,域名所有权等,如果是黑产用的话会这样用吗?会不会暴露自己身份???

    Let's Encrypt 免费通配符 SSL 证书申请教程 from:https://blog.csdn.net/English0523/article/details/79608464 2018 ...

  3. QT开发环境安装配置教程

    QT开发环境安装配置教程 分类: QT2012-11-29 23:31 35366人阅读 评论(12) 收藏 举报 Linux版的直接在ubutnu软件中心输入QT,安装响应的Designer,Cre ...

  4. 2018超详细sublime text3+python3.x安装配置教程(附常用插件安装教程)

    导读 本文是关于2018年7月最新版sublime text3+pythin3.x下载及安装配置教程,sublime text3版本为3176,python版本为3.7,安装环境是基于windows1 ...

  5. centos7命令行和图形界面的相互切换(附centos7安装配置教程)

    一.最近安装了centos7,发现在命令行和图形界面的相互切换命令上,与centos以往版本有很大不同,先整理如下,加深记忆. 1,centos7默认安装后,跟其他版本一样,启动默认进入图形界面: 2 ...

  6. MySQL基础环境_安装配置教程(Windows7 64或Centos7.2 64、MySQL5.7)

    MySQL基础环境_安装配置教程(Windows7 64或Centos7.2 64.MySQL5.7) 安装包版本 1)     VMawre-workstation版本包 地址: https://m ...

  7. Windows基础环境_安装配置教程(Windows7 64、JDK1.8、Android SDK23.0、TortoiseSVN 1.9.5)

    Windows基础环境_安装配置教程(Windows7 64.JDK1.8.Android SDK23.0.TortoiseSVN 1.9.5) 安装包版本 1)     JDK版本包 地址: htt ...

  8. Linux基础环境_安装配置教程(CentOS7.2 64、JDK1.8、Tomcat8)

    Linux基础环境_安装配置教程 (CentOS7.2 64.JDK1.8.Tomcat8) 安装包版本 1)     VMawre-workstation版本包 地址: https://my.vmw ...

  9. Windows上PostgreSQL安装配置教程

    Windows上PostgreSQL安装配置教程 这篇文章主要为大家详细介绍了Windows上PostgreSQL安装配置教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 PostgreSQL的 ...

随机推荐

  1. Stack,ArrayDeque,LinkedList的区别

        本文首发于cartoon的博客     转载请注明出处:https://cartoonyu.github.io/cartoon-blog     这段时间把疯狂JAVA再看了一遍,发现Stac ...

  2. form编码方式application/x-www-form-urlencoded和multipart/form-data的区别?

    application/x-www-form-urlencoded: 表单数据编码为键值对,&分隔 multipart/form-data: 表单数据编码为一条消息,每个控件对应消息的一部分 ...

  3. ARM 汇编 内存访问指令

    一. 单个寄存器操作读写内存 内存访问指令格式:<opcode><cond> Rd, [Rn] Rn 中保存的是一个内存的地址值 1. 内存写指令  [ str,strb,st ...

  4. Struts2.xml的配置

    框架初始知识: Servlet  VS   Filter Filter的性能更强,因为Servlet能实现的,Filter都能实现. Filter还有拦截资源的作用 是Servlet所不能实现的. F ...

  5. Batch - FOR %%a %%b

    总结 %%a refers to the name of the variable your for loop will write to. Quoted from for /?: FOR %vari ...

  6. Change myself to be better

    发现和改变自己不好的习惯 遇到问题的反应 自己遇到问题的时候,特别是不熟悉的问题的时候就会有点焦虑,这个应该是每个人都会有的,遇到自己不熟悉的或者是没有经历过的东西都会 感觉不舒服,或者是遇到难题或者 ...

  7. ZF、TP、CI等各种框架的区别

    (原标题:面试常见问题之ZF.TP.CI等框架的区别 http://blog.163.com/m13341159039_1/blog/static/245953061201522092212820/) ...

  8. HTML——表单标签

    表单标签(掌握) 现实中的表单,类似我们去银行办理信用卡填写的单子. 如下图: 目的是为了收集用户信息. 在我们网页中, 我们也需要跟用户进行交互,收集用户资料,此时也需要表单. 在HTML中,一个完 ...

  9. PHP headers_list() 函数

    定义和用法 headers_list() 函数返回已发送的(或待发送的)响应头部的一个列表. 该函数返回包含报头的数组. 语法 headers_list() 提示和注释 提示:如需确定是否已发送报头, ...

  10. [NOI.AC] palindrome

    思路: \(50pts\) \(f[l,r]\)表示区间\([l,r]\)能够变成多少个串,转移枚举\(l\),利用\(hash\)判字符串相等. 复杂度\(O(Tn^3)\) \(70pts\) 考 ...