博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
网站http改https Let’s Encrypt 安装 续期教程 免费ssl证书Let’s Encrypt使用教程Certbot...
阅读量:6890 次
发布时间:2019-06-27

本文共 4317 字,大约阅读时间需要 14 分钟。

  hot3.png

Certbot项目地址

一、安装

先选择你的web服务器程序和操作系统:

就会出来适合你的情况的安装教程。非常简单,就几步,用的是nginx,VPS系统是centos 7。

三种方式:

第一种:

yum install epel-release yum install certbot certbot certonly

yum install epel-release yum install certbot certbot certonly 运行这个会出来图形安装模式,需要输入域名信息、邮箱、网站目录等。我用这个没有成功。

第二种:

yum install epel-release certbot certonly --webroot -w /var/www/example -d example.com -d www.example.com

#/var/www/example是你的网站目录,example.com和www.example.com是你的域名。

yum install epel-release certbot certonly --webroot -w /var/www/example -d example.com -d www.example.com

#/var/www/example是你的网站目录,example.com和www.example.com是你的域名。 这个其实是和第一种方法是一样的。

第三种:我是用这个成功的

这个需要先停止nginx服务

service nginx stop certbot certonly --standalone -d example.com -d www.example.com

#example.com和www.example.com是你的域名

service nginx stop certbot certonly --standalone -d example.com -d www.example.com

#example.com和www.example.com是你的域名 运行这个肯定能生成证书。生成的位置位于/etc/letsencrypt/live/你的域名/ 目录下。记得备份下。

恢复nginx运行

service nginx start

service nginx start 下面开始配置nginx

我的配置文件如下供参考:

server { listen 443 ssl; #如果需要spdy也可以加上,lnmp1.2及其后版本都默认支持spdy,lnmp1.3 nginx 1.9.5以上版本默认支持http2 server_name www.8dlive.com 8dlive.com; ##这里是你的域名 index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/www.8dlive.com; #网站目录 ssl_certificate /etc/letsencrypt/live/8dlive.com/fullchain.pem; #前面生成的证书,改一下里面的域名就行 ssl_certificate_key /etc/letsencrypt/live/8dlive.com/privkey.pem; #前面生成的密钥,改一下里面的域名就行 ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m;

include wordpress.conf;  #这个是伪静态根据自己的需求改成其他或删除 #error_page 404 /404.html; location ~ [^/]\.php(/|$){ # comment try_files $uri =404; to enable pathinfo try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf;     #lnmp 1.0及之前版本替换为include fcgi.conf; #include pathinfo.conf;} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${ expires 30d;} location ~ .*\.(js|css)?${expires 12h;}access_log  /home/wwwlogs/www.8dlive.com.log;

} server { listen 80; server_name www.8dlive.com 8dlive.com; location /.well-known/ { add_header Content-Type 'text/plain;'; root /home/wwwroot/www.8dlive.com; } location / { return 301 https://www.8dlive.com$request_uri; } }

server { listen 443 ssl; #如果需要spdy也可以加上,lnmp1.2及其后版本都默认支持spdy,lnmp1.3 nginx 1.9.5以上版本默认支持http2 server_name www.8dlive.com 8dlive.com; ##这里是你的域名 index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/www.8dlive.com; #网站目录 ssl_certificate /etc/letsencrypt/live/8dlive.com/fullchain.pem; #前面生成的证书,改一下里面的域名就行 ssl_certificate_key /etc/letsencrypt/live/8dlive.com/privkey.pem; #前面生成的密钥,改一下里面的域名就行 ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m;

include wordpress.conf;  #这个是伪静态根据自己的需求改成其他或删除 #error_page 404 /404.html; location ~ [^/]\.php(/|$){ # comment try_files $uri =404; to enable pathinfo try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf;     #lnmp 1.0及之前版本替换为include fcgi.conf; #include pathinfo.conf;} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${ expires 30d;} location ~ .*\.(js|css)?${expires 12h;}access_log  /home/wwwlogs/www.8dlive.com.log;

} server { listen 80; server_name www.8dlive.com 8dlive.com; location /.well-known/ { add_header Content-Type 'text/plain;'; root /home/wwwroot/www.8dlive.com; } location / { return 301 https://www.8dlive.com$request_uri; } }

自动化更新 Certbot可以配置在过期之前自动续订证书。由于咱们加密证书持续90天,这是非常明智的利用此功能的优势。您可以通过运行该命令来测试你的证书自动更新:

certbot renew --dry-run 1 certbot renew --dry-run 如果出现一切正常,你可以通过添加一个安排自动更新的cron或者systemd运行以下工作:

certbot renew --quiet 1 certbot renew --quiet 或者手动直接运行这个命令来续期,我还没有试过。

二、后续

做完以上步骤,其实有时并不能成功,但不是步骤不对,以上安装证书,配置文件,都没问题,也许是你的网站或者主题有问题。我的就是配置完之后,打开网站始终显示重定向次数过多,我是先把主题改成wordpress的默认的主题,然后进行以上的操作,之后又重新上传了自己的主题,这样就没问题了。

还有一个问题,就是网站的图片链接肯定都是http打头的,要进数据库批量改一下原图片地址的为https,不然只要一个页面有图片,那么这个网页地址那就不会有小绿锁。处理步骤:

1、先去wordpress后台,设置那,把网站地址改成https开头的

2、进数据库,点到wp_posts这个表,点右边搜索,点下面的Find and replace这里查找那里输入

转载于:https://my.oschina.net/yomut/blog/1557226

你可能感兴趣的文章
Nodejs日志管理log4js
查看>>
python获取昨日日期
查看>>
海康威视 - 萤石云开放平台 js 版
查看>>
关于分销平台
查看>>
剑指offer---12-**--数值的整数次方
查看>>
PAT - L2-010. 排座位(并查集)
查看>>
Python 学习笔记 - 线程(线程锁,信标,事件和条件)
查看>>
大数据技术服务商个推获4亿人民币D轮融资
查看>>
Git的详细使用教程
查看>>
iOS实现类似苹果手机原生的锁屏界面(数字密码)
查看>>
[vue] 表单输入格式化,中文输入法异常
查看>>
Observer观察者模式与OCP开放-封闭原则
查看>>
如何搭建高级工程师知识框架?推荐两种方式
查看>>
BAT的医疗春秋大梦
查看>>
Pulsar本地单机(伪)集群 (裸机安装与docker方式安装) 2.2.0
查看>>
利用H5的css3制作动画
查看>>
Android View 事件分发源码分析
查看>>
vue 2.0 - props
查看>>
RustCon Asia 实录 | Rust 在国内某视频网站的应用
查看>>
Vue遇上Analytics
查看>>