在Ubuntu LNMP中设置SSL证书,通常使用Let’s Encrypt免费证书,步骤如下:
sudo apt update
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
(按提示操作,自动配置Nginx)sudo nginx -t # 检查配置语法
sudo systemctl reload nginx # 重载Nginx
sudo certbot renew --dry-run
sudo ufw allow 'Nginx Full'
https://yourdomain.com,查看安全锁图标确认生效。若需使用其他证书(如ZeroSSL),需先生成证书文件,再手动配置Nginx路径。