分类:运维 发布时间:2018-05-24 11:55:00
首先Certbot官网有详细教程,每个版本版本略有不同,ssl证书有效期为3个月,可以自动续期 官网: https://certbot.eff.org/ 以 centos6.5为例安装配置ssl 1、下载安装,并赋予执行权限 ``` wget https://dl.eff.org/certbot-auto chmod a+x certbot-auto ``` 2、执行自动配置 ``` sudo certbot-auto --nginx ``` 如若提示nginx.conf文件路径错误,就手动指向 ``` sudo ./certbot-auto --nginx --nginx-server-root=/usr/local/nginx/conf ``` 默认都选同意,记得填入邮箱。如果看不懂什么意思可以google翻译一下 3、模拟更新证书 ``` sudo ./certbot-auto renew --dry-run ``` 4、添加自动更新证书定时任务 - 编辑定时任务 ``` crontab -u root -e ``` - 粘贴命令 ``` 0 12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && ./path/to/certbot-auto renew ``` - 按 esc 退出编辑模式输入 :wq 保存退出 - 查看任务是否添加成功 ``` crontab -u root -l ``` - 查看crontabs服务状态 ``` service crond status ``` - 如果为启动就启动程序并添加开机自启 ``` service crond start chkconfig crond on ``` 5、手动配置域名 - letsencrypt-auto文件目录中执行 ``` ./letsencrypt-auto certonly --manual -d test.example.com ``` - 验证服务器所有权,先输入Y。显示需要验证的数据并等待 (图) - 新建文件放入在指定目录下 - 回车继续 - 显示成功信息和证书路径 (图) - 打开 nginx 配置443访问(操作省略) - 将80做跳转到443 ``` server { listen 80; server_name test.example.com ; rewrite ^(.*)$ https://$host$1 permanent; } ``` - 重启nginx - 完成配置
搜索
文章分类
最新文章