以下是Ubuntu LAMP服務器的安全設置要點:
sudo apt update && sudo apt upgrade -y
,安裝unattended-upgrades
實現自動更新。/etc/ssh/sshd_config
,設置PermitRootLogin no
、PasswordAuthentication no
,并指定非標準端口(如2222)。sudo systemctl restart sshd
。sudo ufw allow 2222/tcp && sudo ufw allow 80/tcp && sudo ufw allow 443/tcp && sudo ufw enable
。sudo mysql_secure_installation
設置強密碼,刪除匿名賬戶和測試數據庫,限制遠程訪問(如需遠程需配置SSL)。eval
、exec
),關閉錯誤顯示(僅記錄到日志),設置內存限制。/var/log/auth.log
、/var/log/apache2/error.log
)。參考來源: