在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路徑。