Nginx安装免费https证书(Let‘s Encrypt)申请与配置(二)

本文介绍了在Centos8系统上使用Certbot工具为Nginx手动安装LetsEncrypt证书的过程,包括Snap安装Certbot、生成和安装证书、指定域名、使用nginx插件、证书管理及维护等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

上一章节我们梳理了在Centos8操作系统通过certbot工具为Nginx自动安装证书,方便可以查阅文章:

Nginx安装免费https证书(Let‘s Encrypt)申请与配置(一)

本章节继续尝试在Centos8操作系统通过certbot工具为Nginx手动安装证书,参见官网

Certbot官网指南

主要说明Certbot安装证书的一些常用操作,摘录了官网的一部分自认为常用的操作,但是前提还是要安装Certbot,安装方式包括

Snap (Recommended): Certbot Instructions | Certbot

Alternative 1: Docker

Alternative 2: Pip

本次也是按照推荐的方式使用Snap方式安装的,具体见上个章节。

这里需要说明的是之前certbot使用certbot-auto脚本安装证书,包括线上好多文档都是,这个在官网上已经废除了certbot-auto这个脚本,原文链接以及内容如下:

Certbot-Auto [Deprecated]

​ 

说了这么多题外话,接下来说说如何生成证书并且如何使用它,官网提供了好多命令和插件这里以nginx为主,记录其中的操作命令,命令并无严格顺序。

1,生成证书

# Obtain and install a certificate:
certbot

 2,生成证书但不安装

# Obtain a certificate but don't install it:
certbot certonly

3,生成证书并指定具体域名,不同域名可以执行多次

# You may specify multiple domains with -d and obtain and
# install different certificates by running Certbot multiple times:
certbot certonly -d example.com -d www.example.com
certbot certonly -d app.example.com -d api.example.com

为了能为一些web服务器提供快速安装证书能力,certbot提供了一些针对性插件,如对nginx提供了nginx插件,对Apache提供了apache插件,如下截图

4,如果证书生成并安装到nginx上,通过执行如下命令,执行之前需要对你的nginx.conf进行备份

certbot --nginx

  如果想回腿到安装之前状态,可以执行如下命令

certbot --nginx rollback

 5,当然我们想手动执行插件会更灵活,可以手动输入命令和认证需要的参数,这里需要手动指定两个插件

        a.身份验证插件(authenticator),使用参数--authenticator 或者 -a

        b.安装插件(installer),使用参数--installer 或者 -i

举例如下图:

 6,证书管理

查看证书的详细内容,通过如下命令

certbot certificates

执行后返回内容包括证书对应的域名,证书路径以及私钥

7,使用--cert-name 配合run, certonly, certificates, renew,  delete使用 

certbot certonly --cert-name example.com

为example.com生成证书

8,重新生成或更新证书

certbot --expand -d existing.com,example.com,newdomain.com
#或
certbot --expand -d existing.com -d example.com -d newdomain.com

9,删除域名下的证书

certbot delete --cert-name example.com
# or to choose from a list:
certbot delete

还有更多的执行命令,请参见

Getting certificates (and choosing plugins)¶

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NettyBoy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值