准备

需要python版本为2.7以上,所以centos6需要把2.6升级成2.7

升级python

###安装python2.7
tar -xvf Python-2.7.5tar.bz2
cd Python2.7
./configure --prefix=/usr/local/python2.7 && make && make install ###安装python2.7对应的pip
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-20.3.1.tar.gz
tar -xvf setuptools-20.3.1.tar.gz
cd setuptools-20.3.1
/usr/local/python2.7/bin/python2.7 setup.py install --prefix=/usr/local/python2.7
wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.1.tar.gz
tar -xvf pip-8.0.1.tar.gz
cd pip-8.0.1
/usr/local/python2.7/bin/python2.7 setup.py install --prefix=/usr/local/python2.7

迁移python

步骤:

把/usr/bin/python和pip改名为python2.6和pip2.6

mv /usr/bin/python /usr/bin/python2.6
mv /usr/bin/pip /usr/bin/pip2.6

修改yum配置文件指定python版本为python2.6

vim /usr/bin/yum
#!/usr/bin/python 改为 #!/usr/bin/python2.6

把/usr/bin/python2.7和pip2.7改名为python和pip

ln -s  /usr//local/python2.7/bin/python2.7 /usr/bin/python
ln -s /usr/local/python2.7/bin/pip2.7 /usr/bin/pip2.7

解释:因为yum需要依赖原来的python2.6

更改pip源

mkdir ~/.pip
cat > ~/.pip/pip.conf << EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/
EOF

利用Let's Encrypt 免费生成HTTPS证书

  1. 下载安装certbot(Let's Encrypt )
  2. 利用certbot生成证书
  3. 配置nginx的https证书

安装cerbot

[root@hz1 ~]# wget https://dl.eff.org/certbot-auto
[root@hz1 ~]# chmod a+x certbot-auto
[root@hz1 ~]#./certbot-auto  

利用certbot生成证书

给一个域名生成证书

[root@hz1 certbot]# ./certbot-auto certonly --email  zhai.junming@timecash.cn --agree-tos --webroot -w  /alidata1/www/timecash22/api3  -d  xxxx.zjm.cn
/root/.local/share/letsencrypt/lib/python2./site-packages/cryptography/__init__.py:: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
DeprecationWarning
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Obtaining a new certificate
Performing the following challenges:
http- challenge for xxx.zjm.cn
Using the webroot path /alidata1/www/timecash22/api3 for all unmatched domains.
Waiting for verification...
Cleaning up challenges IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/xxx.zjm.cn/fullchain.pem. Your
cert will expire on --. 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 -w:指定域名的根目录
-d:指定域名

Note:证书已经生成到了/etc/letsencrypy/live/xxx.zjm.cn下

Nginx配置https证书

server {
listen ssl;
....
ssl_certificate /etc/letsencrypt/live/xxx.zjm.cn/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xxx.zjm.cn/privkey.pem;
ssl_dhparam /etc/nginx/ssl/dhparam.pem; }

ssl_certificate和ssl_certificate_key分别对应fullchain.pem,privkey.pem

ssl_dhparam通过以下命令生成

$ sudo mkdir /etc/nginx/ssl
$ sudo openssl dhparam -out /etc/nginx/ssl/dhparam.pem

给多个域名生成一个证书,也就是多个域名使用一个ssl证书

./certbot-auto certonly --email admin@laobuluo.com --agree-tos --webroot -w /var/www/laozuo -d laozuo.org -d www.laozuo.org -w /var/www/laobuluo -d laobuluo.com -d www.laobuluo.com

迁移证书

需求:需要域名的解析IP变到另一台服务器了,需要把证书迁移过去

在原来服务器上吊销证书

 ./certbot-auto    revoke   --cert-path /etc/letsencrypt/live/app.wl.aaa.cn/fullchain.pem
#直接指定域名的证书路径就能吊销证书,千万不能直接删除

在新的服务器上重新申请证书

自动更新https证书

由于这个免费的证书只有90天的使用时间,所以遇到定时更新以下证书,这里是利用certbot每隔一段时间自动更新证书

手动执行更新

./certbot-auto  renew --dry-run

结合crontab每隔一段时间自动更新证书

  * *  ./certbot-auto  renew  >> /var/log/le-renew.log

域名添加HTTPS的更多相关文章

  1. 阿里云虚拟主机的域名添加https的方法

    第一步:购买CDN套餐,阿里云虚拟主机目前是不支持https的,不过可以通过阿里云的CDN服务来跳转一下实现部署https 静态HTTPS请求数根据你的网站访问量来选择 第二步:申请SSL证书服务,有 ...

  2. cas+tomcat+shiro实现单点登录-1-tomcat添加https协议

    目录 1.tomcat添加https安全协议 2.下载cas server端部署到tomcat上 3.CAS服务器深入配置(连接MYSQL) 4.Apache Shiro 集成Cas作为cas cli ...

  3. 八大免费SSL证书-给你的网站免费添加Https安全加密

    评论»   https://www.freehao123.com/top-8-free-ssl-cert/ 文章目录 Let's Encrypt StartSSL SSL CloudFlare SSL ...

  4. IIS7二级域名添加同一证书

    IIS7二级域名添加同一证书, 先绑定第一个域名到443 ,之后的用以下命令行绑定 cd C:\Windows\System32\Inetsrv\appcmd set site /site.name: ...

  5. [转帖]一个ip对应多个域名多个ssl证书配置-Nginx实现多域名证书HTTPS

    一个ip对应多个域名多个ssl证书配置-Nginx实现多域名证书HTTPS https://home.cnblogs.com/u/beyang/ 一台服务器,两个域名 首先购买https,获取到CA证 ...

  6. 在Azure中搭建Ghost博客并绑定自定义域名和HTTPS

    绪论 之前一直使用cnblog写博客,现在将博客迁移至Microsoft Azure上的Ghost博客上,Ghost博客使用Markdown书写博客,页面简洁,是我喜欢的风格.具体参见官网:https ...

  7. apache添加https证书

    今天折腾了一下,总结apache添加https证书的方法. 证书类型分为两种, A)自签名证书 利用oepnssl命令生成.csr和key文件,没有授信,没有有效期,但是可以强制使用https协议,可 ...

  8. 一文搭建自己博客/文档系统:搭建,自动编译和部署,域名,HTTPS,备案等

    本文纯原创,搭建后的博客/文档网站可以参考: Java 全栈知识体系.如需转载请说明原处. 第一部分 - 博客/文档系统的搭建 搭建博客有很多选择,平台性的比如: 知名的CSDN, 博客园, 知乎,简 ...

  9. Windows Server2008 R2 服务器域名设置Https安全证书访问

    域名支持Https访问设置 1.首先登陆域名申办公司的域名管理账号添加TXT域名解析信息 以新网域名公司为例:http://dcp.xinnet.com,输入域名:www.xxx.com和密码登录即可 ...

随机推荐

  1. linux 11201(11203) ASM RAC 安装

    注意:11G的RAC安装,如果升级,则会新建目录在放软件,原来的不删除,所以所需空间比较大. 1.安装系统,把所有的开发包全部安装上 关掉防火墙和SELinux yum -y install comp ...

  2. SpringCloud 微服务框架

    学习资源:https://ke.qq.com/course/280057 知识体系分为以下几点: 1)使用Eureka搭建注册中心,包括 服务生产者.服务消费者(也称服务注册与发现): Zookeep ...

  3. 導出Excel方法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  4. 使用python划分数据集

    无论是训练机器学习或是深度学习,第一步当然是先划分数据集啦,今天小白整理了一些划分数据集的方法,希望大佬们多多指教啊,嘻嘻~ 首先看一下数据集的样子,flower_data文件夹下有四个文件夹,每个文 ...

  5. 指定PHP编码

    有时候我们写好的PHP页面在网页中打开是乱码的,就需要指定编码,即加入代码: header("content-type:text/html;charset=utf-8"); 位置图 ...

  6. Java随机数使用

    JAVA取随机数的三种方式: Math.random() System.currentTimeMillis() random.nextInt() 废话不多说,看代码: /** *取单个随机数 *Mat ...

  7. viewDidLoad等相关函数调用

    viewDidLoad 此方法只有当view从nib文件初始化的时候才被调用.viewDidLoad用于初始化,加载时用到的. loadView 此方法在控制器的view为nil的时候被调用.虽然经常 ...

  8. tinyxml

    在TinyXML中,根据XML的各种元素来定义了一些类:        TiXmlBase:整个TinyXML模型的基类.        TiXmlAttribute:对应于XML中的元素的属性.   ...

  9. node 转二进制 图片

    'use strict';const Service = require('egg').Service;const fs = require('fs');const path = require('p ...

  10. SpringBoot Banner 图片定制修改

    启动Spring Boot项目的时候,在控制台会默认输出一个启动图案 这个图案如果你需要的话是可以自己修改的,修改方式很简单: 1. 在src/main/resources下新建一个banner.tx ...