在Debian LAMP环境下安装SSL证书,你可以选择使用Let’s Encrypt免费证书或者购买一个SSL证书。以下是使用Certbot(Let’s Encrypt官方推荐的客户端)安装SSL证书的步骤:
安装Certbot: 在终端中运行以下命令来安装Certbot及其Apache插件:
sudo apt update
sudo apt install certbot python3-certbot-apache
获取SSL证书:
运行以下命令来获取SSL证书。请将yourdomain.com
替换为你的域名:
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com
Certbot会自动配置Apache以使用SSL,并将证书文件存储在/etc/letsencrypt/live/yourdomain.com/
目录下。
自动续期: Let’s Encrypt证书有效期为90天,Certbot会自动设置一个定时任务来检查并续期证书。你可以使用以下命令手动测试续期过程:
sudo certbot renew --dry-run
如果一切正常,Certbot会输出一条消息,说明续期成功。
重启Apache: 如果你在安装过程中修改了Apache配置文件,或者手动修改了配置文件,需要重启Apache服务以使更改生效:
sudo systemctl restart apache2
现在,你的Debian LAMP服务器已经成功安装了SSL证书,可以通过https://yourdomain.com
访问你的网站。浏览器地址栏中的锁图标表示连接已加密。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: Debian支持哪些Golang版本