nginx配置https

证书网站

https://letsencrypt.org/zh-cn/getting-started/
在这里插入图片描述
点击访问certbot,选择对应容器以及系统版本
查看系统版本

uname -a

我这里是centos 7
在这里插入图片描述
在这里插入图片描述
选完之后下面会有提示
在这里插入图片描述

安装snapd

1.首先安装COPR插件和EPEL,通过添加epel存储库并安装copr yum插件来启动安装,运行如下命令:

yum -y install epel-release
yum -y install yum-plugin-copr

2.然后添加repo:

yum copr enable ngompa/snapcore-el7

3.添加存储库后,安装snapd软件包,运行以下命令:

systemctl enable --now snapd.socket

4.限制需要从/snap到/var/lib/snapd/snap下的/snap或符号链接下的snaps,为它创建一个符号链接,如下命令:

ln -s /var/lib/snapd/snap /snap

安装完成
配完直接使用snap可能会碰到这个问题,稍等下就好
error: too early for operation, device not yet seeded or device model not acknowledged

使用snap下载速度可能会很慢,可以自行翻墙或者使用加速器

安装certbot

按照下列操作继续
snap install --classic certbot

第七步时可能会出现以下问题

1.Saving debug log to /var/log/letsencrypt/letsencrypt.log.The nginx plugin is not working; there may be problems with your existing configuration.

The error was: NoInstallationError(“Could not find a usable ‘nginx’ binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.”)
相当于window的环境变量,nginx不能直接访问到,需要配置软链接。
执行which nginx
将nginx链接到以下任意地址即可,前面是自己的安装路径,后面是要链到的路径
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx 在这里插入图片描述

2.The nginx plugin is not working; there may be problems with your existing configuration.The error was: PluginError(‘Nginx build is missing SSL module (–with-http_ssl_module).’)

nginx没有启用http_ssl_module模块
到nginx的源文件目录,执行

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

然后make

make

查看状态(注意不要直接nginx -V,因为之前链接了根路径,直接nginx命令会找到之前的),我当前在源文件目录,不在的自行加上全路径

objs/nginx -V

在这里插入图片描述
出现图片内容即可
然后备份之前的nginx

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

将新编译出来的nginx替换原来的

cp objs/nginx /usr/local/nginx/sbin/nginx

下面按需执行即可
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值