申请免费SSL证书并自动续期,https让网站更安全!

使用EFF的Certbot在网站上自动启用HTTPS,部署 Let的加密证书。

Certbot

  Certbot是Let’s Encrypt推出的获取证书的客户端,可以让我们免费快速地获取Let’s Encrypt证书。

安装

在centos7环境中使用nginxTengine配置https

yum -y install yum-utils
yum-config-manager –enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

  • 执行此操作后,可以通过运行以下命令安装Certbot:

yum install python2-certbot-nginx

  • Certbot有一个Nginx插件,在许多平台上都支持,并且安装了证书。

certbot –nginx

  • 到现在为止,你应该可以启动certbot了,但是由于我们用的是源码的方式安装的nginx

  • 运行此命令将为您获取证书,并让Certbot自动编辑您的Nginx配置以提供服务。如果您感觉更加保守并想手动更改Nginx配置,则可以使用certonly
    子命令:

certbot –nginx certonly

  • 如果您想使用Let’s Encrypt的新ACMEv2服务器获取通配符证书,您还需要使用
    Certbot的DNS插件之一。为此,请确保使用上述说明安装DNS提供程序的插件,并运行如下命令:

    certbot -a dns-plugin -i nginx -d“* .example.com”-d example.com –server https://acme-v02.api.letsencrypt.org/directory

  • 由于let’s encrypt期限为3个月,所以可以使用certbot的更新机制更新,也可以把其.放入定时任务。


YUM下Loaded plugins: fastestmirror Determining fastest mirrors 的错误问题
Centons下
其大概意思是fastestmirror不能使用,fastestmirror是yum的一个加速插件,具体我也没有仔细了解过,可能是系统不支持或者缺少组建导致的。处理办法就是禁用这个插件,方法如下:

vi /etc/yum/pluginconf.d/fastestmirror.conf

[main]
enabled=0 //把1改为0
verbose=0
socket_timeout=3
hostfilepath=/var/cache/yum/timedhosts.txt
maxhostfileage=10
maxthreads=15
exclude=.gov, facebook

修改以下配置文件

root@localhost#vi /etc/yum.conf

[main]
cachedir=/var/cache/yum/ b a s e a r c h / releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1 #将plugins的值修改为0
installonly_limit=5


启动时候可能会报错,报错如下:

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()

产生这个错误的原因是因为certbot找不到nginx的安装位置,认为你没有安装nginx。如果你使用的是yum进行nginx的安装,就不会出现这样的情况。那么解决这个的办法就是,我们使用软连接,告诉certbot,nginx的目录在哪。

把nginx的目录和/etc/nginx建立连接。

mkdir /etc/nginx
ln -s /usr/local/nginx/conf/* /etc/nginx/

猜你喜欢

转载自blog.csdn.net/nrah123/article/details/81980614