现在配置 SSL 证书实现 https 非常简单了

各大服务商都有商用的 SSL 证书卖,对个人站点来说费用还是有点高。可能贵有贵的道理。不过使用 Let's Encrypt 实现 https,现在已经可以用三分钟部署成功了。

首先,你得保证你的 http 站点已经正常上线、运行、可访问。

其次,跟着 Certbot 官方教程 走:

sudo apt update
sudo apt install python3 python3-venv libaugeas0
sudo apt-get remove certbot
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-apache
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
sudo certbot --apache
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

最后,成功了。就是这么简单。只要没有网络问题,这已经成功给你的网址签发 SSL 证书了,别人访问时会自动跳转到 https 页面;通过 https 页面,也会正常访问你的网站。

本教程适用的平台
适用 不适用
Debian CentOS
Apache2 Nginx