Debian LAMP 远程管理实践指南
一 基础安全与连通性
sudo ufw allow 'Apache Full' && sudo ufw enable 或 sudo ufw allow 80,443/tcp && sudo ufw enable。sudo apt install openssh-server -y,随后 sudo systemctl enable --now ssh。PubkeyAuthentication yes,禁用密码登录 PasswordAuthentication no,重启服务 sudo systemctl restart ssh。sudo ufw allow 22/tcp),避免被锁死。二 远程管理 Web 与数据库
sudo systemctl enable --now apache2。bind-address 改为 0.0.0.0(或注释掉该行)以监听所有地址。sudo systemctl restart mysql。CREATE USER 'admin'@'%' IDENTIFIED BY 'StrongPass!'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;CREATE USER 'admin'@'203.0.113.10' IDENTIFIED BY 'StrongPass!'; GRANT ALL PRIVILEGES ON db.* TO 'admin'@'203.0.113.10'; FLUSH PRIVILEGES;ssh -L 3306:localhost:3306 user@server_ip,本地连接 127.0.0.1:3306 即可安全管理远端数据库。三 图形化与浏览器内管理
sudo apt install phpmyadmin 按向导配置;为安全起见,建议将其置于 HTTPS 与受限目录,或通过反向代理与认证限制访问。sudo apt install cockpit 后启用服务 sudo systemctl enable --now cockpit.socket,在浏览器访问 https://服务器IP:9090,可进行系统监控、日志查看、服务管理以及终端操作,适合轻量化远程运维。四 自动化与批量运维
sudo apt install ansible -y,编写 Playbook 统一管理多台 Debian LAMP 主机。五 安全加固清单
AllowUsers/AllowGroups)。sudo apt install unattended-upgrades -y && sudo dpkg-reconfigure unattended-upgrades,定期审计日志与用户。