ILD

使用Let's Encrypt部署HTTPS网站
作者:Herbert Yuan 邮箱:yuanjp@hust.edu.cn
发布时间:2017-11-8 站点:Inside Linux Development

Let's Encrypt提供免费的SSL/TLS认证,并且提供certbot工具自动部署到Apache。


Step 1

打开 https://certbot.eff.org/ ,选择Software和System后,将提供使用命令:

1
2
3
4
5
6
7
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache 
 
sudo certbot --apache

命令执行成功后,应该可以打开https了。


Step 2

certbot可以选择配置成http跳转到https,如果没有选择的话,可手动配置.htaccess文件,添加:

1
2
RewriteCond %{SERVER_PORT} !^443$  
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R]


Step 3

certbot过期时间为90天,可添加一个cron定时任务,自动更新证书。使用crontab -e添加下述行:

1
4 4 1 * * certbot renew  >> /var/log/le-renew.log

配置成每月1号的4点4分更新证书,你应该配置一个别的合适的时间。


最后,记得donate一下,支持开源社区。写这篇文章时,本站刚刚用上述方法更新为https。

Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.