有免费的https证书,不用花钱.有两个问题,1需要命令行申请,2需要更新
1.下载一个叫certbot的东西.还好开箱即用.
https://github.com/certbot/certbot找一个版本吧
这是下载链接替换一下版本就可以下下来了https://github.com/certbot/certbot/archive/v0.30.0.tar.gz
2.rz到服务器上,服务器上wget的忽略
3.tar -xzvf certbot-030.0.tar.gz
4.cd certbot-030.0
5.申请一个免费的https证书
./letsencrypt-auto certonly --webroot -w /data/www/liuzeyi.com.cn/web -d liuzeyi.com.cn --no-self-upgrade
(1)参数说明:
-w : 根目录位置,就是web可访问目录
-d : 域名,需要申请的域名
--no-self-upgrade : 不更新自己.不然的话会更新certbot相关的好多东西,会慢呀会有报错呀会有依赖维护呀...
(2)注意:
首先要使域名可以访问,其次-w的目录是可以访问的通过域名/1.html这种
为什么呢?我不知道,我没启动nginx是会报错的.
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain:
Type: unauthorized
Detail: Invalid response from
http:// /.well-known/acme-challenge/5AFuc8XyOwrQMqfgHIxCGKsdiVfV5rRAUkh89hxLeFI
[...]: "<!doctype html>\n<html
lang=\"zh\">\n<head>\n\t\t<meta charset=\"UTF-8\">\n\t\t<meta
name=\"viewport\" content=\"width=device-width, user-scala"
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
我推测是为了做验证,这个域名是不是你的.这台机器是不是你的.应该会往-w里面写一些东西,在网络上能访问到就是你的了.
(3)注意:
你可能会碰到
Bootstrapping dependencies for Legacy RedHat-based OSes that will use Python3... (you can skip this with --no-bootstrap)
yum is hashed (/usr/bin/yum)
To use Certbot on this operating system, packages from the SCL repository need to be installed.
Enable the SCL repository and try running Certbot again.
好吧,这是说有个叫SCL的没有.我找半天也没整明白怎么装上.我用了一个办法不断尝试版本,发现0.30.0能用.(0.40.0,1.2.0不能用我的服务器)
(4)注意
有可能会碰到python2...不知道2点几了版本低的问题.我一顿配置升级python2->python3点几.结果还是不行.我怀疑certbot有些版本是通过yum管理的,yum只能用python2的.(certbot0.15.0不行),通过找好使的certbot版本可以解决这个问题.
(5)注意
python版本低,python还是得升级的../configure 之后make & make install,我升级到3.4就可以用了.
python升级的时候需要改,python的实际指向,挂一个软连接到python3上,还有一个python-config文件也是,也要保留原有的python2版本,给yum用.修改yum文件/usr/bin/yum 第一行.使用python2就好了.
(6)注意
升级完事儿.配置nginx,正常/etc/letsencrypt/live下面的是现在生效的,配置上就行了.之后重启,一定要重启nginx.要不不生效
6.更新证书
简单了.直接./letsencrypt-auto renew --no-self-upgrade这时候会自动更新live里面的文件不用担心nginx里面的配置.但是也需要重启nginx,因为配置文件路径没变但是文件内容已经变了
7.总结
其实是很简单的事儿.下certbot,执行命令.过程中有很多波澜,这儿那儿都缺.能百度装就装,装不了.用新版本.伟大的开发者们会给我们解决这些不好用的问题的.
8.复习下linux命令
(1)软连接:
ln -s 原文件 新文件
(2)复制,重命名cp,mv
(3)查找同名文件find ./ -name 'certbot'
(4)查找目录下有python的文件 ll -a | grep 'python'