以下是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
)。参考来源: