假设运行环境为centos6.8,Web 服务器是 Nginx 1.12.0(因为我的生产环境是),python2.6.6 当前工作目录为 /root
获取certbot客户端
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto

停止nginxservice nginx stop
生成证书
./certbot-auto certonly --standalone --email 你的邮箱地址 -d 你的域名地址

当前网站有多个域名时需在后面增加,例如
./certbot-auto certonly --standalone --email 你的邮箱地址 -d 你的域名1 -d 你的域名2
例如:
./certbot-auto certonly --standalone --email ‘*******@qq.com’ -d ‘www.pvpvv.com’

ssl_certificate /etc/letsencrypt/live/www.pvpvv.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/www.pvpvv.com/privkey.pem;启动nginxservice nginx start

No module named yum错误的解决办法
今天用yum安装软件的时候出现如下错误:
There was a problem importing one of the Python modules required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or verify that the module is installed correctly.
It’s possible that the above module doesn’t match the current version of Python, which is:
If you cannot solve this problem yourself, please go to the yum faq at:

yum 错误,搜索一番后知道是yum和Python是依赖关系,yum是python的模块,所以采用以下解决方案:

系统python的当前版本 Python 2.7

肯定是yum的版本与当前python的版本不一致造成的
所以修改yum的配置,修改文件: vim /usr/bin/yum
修改头#!/usr/bin/python => #!/usr/bin/python2.6
再次检查python版本
[dup@localhost Python-2.7.14]$ python --version
Python 2.7.14
目前已经是新版本。
解决系统 python 软链接指向 python2.7 版本后,因为yum是不兼容 python 2.7的,所以yum不能正常工作,需要指定 yum 的python版本。
[dup@localhost Python-2.7.14]$ yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It’s possible that the above module doesn’t match the
current version of Python, which is:
2.7.14 (default, Jan 19 2018, 00:52:34)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
#vim /usr/bin/yum
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6
生成证书
./certbot-auto certonly --standalone --email ‘@qq.com’ -d ‘www.pvpvv.com’
Package python-devel-2.6.6-66.el6_8.i686 already installed and latest version
No package python-virtualenv available.
Package python-tools-2.6.6-66.el6_8.i686 already installed and latest version
No package python-pip available.
Package 1:mod_ssl-2.2.15-69.el6.centos.i686 already installed and latest version
Nothing to do
Creating virtual environment…
./certbot-auto: line 1004: virtualenv: command not found
没有python-pip和python-virtualenv
安装python-pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pypython get-pip.py
安装python-virtualenvpip install virtualenv停止nginxservice nginx stop
再次生成证书
./certbot-auto certonly --standalone --email '
@qq.com’ -d ‘www.pvpvv.com’
提示成功:
IMPORTANT NOTES:

  • Congratulations! Your certificate and chain have been saved at:
    /etc/letsencrypt/live/www.pvpvv.com/fullchain.pem
    Your key file has been saved at:
    /etc/letsencrypt/live/www.pvpvv.com/privkey.pem
    Your cert will expire on 2019--. To obtain a new or tweaked
    version of this certificate in the future, simply run certbot-auto
    again. To non-interactively renew all of your certificates, run
    “certbot-auto renew”

  • If you like Certbot, please consider supporting our work by:

    Donating to ISRG / Let’s Encrypt: https://letsencrypt.org/donate
    Donating to EFF: https://eff.org/donate-le

查看生产的证书
tree /etc/letsencrypt/live/
nginx配置server {
listen 80; server_name www.pvpvv.com;
return 301 https://www.servernameserver_nameservern​amerequest_uri;
}

server{
listen 443 ssl;
server_name www.pvpvv.com pvpvv.com;ssl on;
ssl_certificate /etc/letsencrypt/live/www.pvpvv.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.pvpvv.com/privkey.pem;
ssl_session_timeout 5m;ssl_protocols SSLv3 TLSv1;ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
index index.html index.php;
root /home/www;
location / {
proxy_pass http://web服务的ip或者域名
}
}

查看nginx配置nginx -t

启动nginxservice nginx start

listen 80端口主要是为了在用户访问网站的时候未输入https,使用http的方式访问80,则自动跳转请求https的访问地址

重启nginx:
nginx -s reload

https自动更新:
配置crontab
由于let’s encrypt 生成的CA证书有效时间只有3个月,所以在CA证书到期以后我们需要手动进行更新,重新获取,或者使用Linux的crontab定时任务定时获取
首先完成步骤3后检测能否正常更新证书:
./certbot-auto renew --dry-run

然后编辑自定义脚本regen.sh:

#!/bin/bash

续签

/usr/bin/certbot renew --quiet

重启 nginx

/usr/sbin/nginx -s reload

查看任务列表
crontab -l

增加cron
crontab -e

注意如果是首次添加则会选择编辑器,按找自己习惯选择就行,我这里选择的是vi
在文件末尾追加:

每个月的1号 03:00 运行
00 03 1 * * /youpath/regen.sh

执行此脚本测试是否正常:
chmod +x regen.sh
./regin.sh

重启crontab
sudo systemctl restart cron

永久免费安装https方法相关推荐

  1. Xshell6和Xftp官网下载个人永久免费授权版方法和作者已下载好的安装包下载链接

    Xshell6和Xftp官网下载方法和安装包 作者本人也是在茫茫网海中浮沉了许久,终于找到了官网免费下载个人免费使用版本的下载办法,需要的朋友就跟随我操作下载吧,当然此处也会附上我已经下载好的安装包下 ...

  2. 卡巴斯基KAV/KIS 6.0/7.0 永久免费激活方法

    转自卡巴技术论坛 http://www.kpchina.net/bbs/thread-17524-1-1.html KAV/KIS 6.0/7.0 永久免费激活方法 以前得到过卡巴6.0的永久免费激活 ...

  3. KAV/KIS 6.0 7.0 永久免费激活方法

    以前得到过卡巴6.0的永久免费激活的方法,今天试了试KIS7.0.0.123上面,发现竟然也可以用啊!卡巴太好了!我以为新版肯定把注册表位置改了--没想到竟然没有!哈哈!方法如下: Free Acce ...

  4. 老板说“把系统升级到https”,我用一个脚本实现了,而且永久免费!

    点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 现在很多站长都会考虑将自己的站点从http升级到https,不仅是 ...

  5. 永久免费http升级到https

    http与https的区别 为了数据传输的安全,https在http的基础上加入了ssl协议,ssl协议依靠证书来验证服务器的身份,并为浏览器和服务器之间的通信加密.要想将http升级为https,只 ...

  6. Pycharm社区版安装教程(永久免费,随时升级)

    首先进入JetBrain的官网(国内正常访问): https://www.jetbrains.com/ 第一眼看到的界面如下图所示: 然后找到我们的Pycharm专题页: 进入Pycharm的专题页面 ...

  7. 卡巴斯基KAV/KIS 6.0/7.0 授权许可文件永久免费更新方法

    针对最近一段时间卡巴斯基的官方网站大量封杀各种版本杀毒软件的授权许可文件和激活码,给广大的兄弟朋友们造成了很大的麻烦和困惑!为此,我特意整理了一些修改卡巴自身文件的方法和技巧.来实现永久免费使用卡巴斯 ...

  8. LINUX服务器最简洁的HTTPS免费证书配置方法

    注意:该方法已在多台服务器配置了免费的https证书,无论是更新还是第一次配置都运行成功:由于是免费版,每个证书都只有三个月的有效期,也无法保证安全和稳定性,所以只建议做测试用,客户的项目需要时,请让 ...

  9. 免费得到HTTPS证书方法

    开发微信小程序时,要求发布的站点要求HTTPS证书.然后CHROME浏览器现在都默认将HTTP的站点显示为不安全.看来,必须得让自己的平台也加上HTTPS了.同时GODADDY的HTTPS证书,一个证 ...

最新文章

  1. HDU-4532 湫秋系列故事——安排座位 组合数学DP
  2. 端计算(3)-kotlin(1)
  3. 使用VS2019创建项目,添加文件和库地址
  4. 团队Alpha冲刺(三)
  5. oracle flashback 深入研究,oracle 之flashback 深入研究。
  6. 面试官爱问的10大经典排序算法,20+张图来搞定
  7. Mac M1安装ffmpeg报错DependencyNotInstalled: Found neither the ffmpeg nor avconv executables.
  8. TestNg测试框架使用
  9. MyBatis学习(二)使用注解开发、Mybatis 执行流程、一对多多对一的结果集映射
  10. CentOS7.5中Moodle 3.7之PHP Cli(命令行)方式安装
  11. php 获取第一个字符串的大写首字母(中文)
  12. 如何利用用户分层来提高运营效率?
  13. almon多项式_计量经济学 总结.docx
  14. 谷歌浏览器关闭安全模式, 访问 http网站
  15. cuda必须装在c盘吗_软件安装到C盘会影响计算机运行速度吗?一个问题引发的思考...
  16. 【微信小程序】——Mobx全局数据共享和分包
  17. 查看电脑连接过的所有无线的密码
  18. SQL Server:国信证券赢在数字化转型起跑线的利器
  19. Effective C++ 规则39:明智而谨慎的使用private继承
  20. 使用Windows Defender Atp进行威胁狩猎

热门文章

  1. 地质地貌卫星影像集锦(三 矿产资源篇)
  2. CSDN首发丨TBSchedule应用实战手册
  3. springboot高校学生健康档案管理系统java ssm
  4. 心学与技术-软件的意义
  5. 计算机基本知识实训报告,计算机基础实训报告总结
  6. echarts 图表导出PDF(带滚动条)/图片导出PDF
  7. 加密技术:加密软件的三种方式
  8. 详解Arduino Uno开发板的引脚分配图及定义
  9. 城市大脑建设的3个误区,大脑模型的分歧是关键
  10. 蓝桥杯 算法提高 逃跑的牛(BFS)