Let’s Encrypt提供了免费的证书,而且非常简单
参考Certbot Instructions | Certbot (eff.org)即可。这里记录一下操作过程,跟文档是一样的。
- 安装,apt python3 python3-venv libaugeas0
- 移除certbot,以防万一的操作。apt remove certbot
- 创建虚拟环境,我对python不熟悉,照敲而已,python3 -m venv /opt/certbot/
- 安装certbot和certbot-nginx,/opt/certbot/bin/pip install certbot certbot-nginx
- 创建软连接,ln -s /opt/certbot/bin/certbot /usr/bin/certbot
- 设置证书,certbot –nginx
不得不说这玩意真高级!
网上查了说证书有效期是90天,所以还是得把文档中最后的自动续期的定时任务加上
echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
在用pip安装certbot和certbot-nginx时遇到了网络问题,懂的人都懂,可以设置一下使用阿里云的源,操作方法就是在~/.pip/pip.conf中添加如下设置:
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
不得不赞一下阿里云,大气!
发表回复