letsencrypt 证书申请 centos7 nginx

Nginx · Fecmall · 于 2年前 发布 · 1711 次阅读

letsencrypt 证书支持泛域名,也就是一个证书,支持N个子域名, 证书有效期为3个月,可以免费续时间,您可以使用cron自动执行

官网文档:https://certbot.eff.org/lets-encrypt/centosrhel7-nginx

您可以根据自身系统,选择合适的版本

centos7 操作系统,nginx安装证书,详细:

1.安装snapd

文档:https://snapcraft.io/docs/installing-snapd

点击centos,跳转到:https://snapcraft.io/docs/installing-snap-on-centos

1.1Adding EPEL to CentOS 7

sudo yum install epel-release

1.2

sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap

2.确保您的 snapd 版本是最新的 在机器上的命令行执行以下说明,确保您拥有最新版本的 snapd。

sudo snap install core; sudo snap refresh core

3.删除 certbot-auto 和任何 Certbot OS 包

如果安装了,请删除包 apt, dnf, or yum

apt安装方式删除:sudo apt-get remove certbot
dnf安装方式删除:sudo dnf remove certbot
yum安装方式删除:sudo yum remove certbot.

4.安装Certbot

sudo snap install --classic certbot

5.Prepare the Certbot command

Execute the following instruction on the command line on the machine to ensure that the certbot command can be run.

sudo ln -s /snap/bin/certbot /usr/bin/certbot

6.选择您希望如何运行 Certbot

6.1一步一步的方式,进行配置,完成后,将会修改nginx的配置文件

sudo certbot --nginx

如果是宝塔,可以执行:

sudo certbot --nginx --nginx-server-root=/www/server/nginx/conf

6.2手动修改nginx配置文件(建议使用6.1)

sudo certbot certonly --nginx

nginx重启。

7.测试自动续订 您系统上的 Certbot 软件包带有一个 cron 作业或 systemd 计时器,它们会在您的证书到期之前自动更新您的证书。 除非您更改配置,否则您无需再次运行 Certbot。

您可以通过运行以下命令来测试证书的自动续订:

sudo certbot certonly --nginx

如果是宝塔,可以执行:

sudo certbot certonly --nginx --nginx-server-root=/www/server/nginx/conf

8.打开商城,查看https是否配置成功。

共收到 4 条回复
Fecmall#12年前 0 个赞

1.对于腾讯云,阿里云这些,需要在安全组里面开放443端口

2.对于宝塔, 如果手动设置ssl,那么需要去宝塔里面开启443

https://www.fecmall.com/topic/5493

adamwyj#22年前 0 个赞

6.1时报错如下,Nginx无法重启, 但手动重启后所有域名的SSL生效了。 NEXT STEPS:

  • The certificate was saved, but could not be installed (installer: nginx). After fixing the error shown below, try installing it again by running: certbot install --cert-name tepa.cc

nginx restart failed: nginx: [emerg] unexpected "{" in /www/server/panel/vhost/nginx/www.tepa.cc.conf:317

3楼 已删除.
Fecmall#42年前 0 个赞

得用centos7以上版本的linux操作系统

这是官网文档:https://certbot.eff.org/lets-encrypt/centosrhel7-nginx

出现报错,自己搜搜吧,我搭建试过,没问题

adamwyj#51年前 1 个赞

@Fecmall #4楼 已解决, 谢谢

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics