为什么要用检查清单
DMIT 云服务器开通后,第一个小时是安全加固和基础配置的关键窗口。按照检查清单逐步操作,可以避免遗漏关键步骤,减少后续维护的麻烦。
本文将首次部署分为四个阶段:系统初始化、安全加固、服务部署、监控与备份。每一步都附有具体命令和验证方法。
阶段一:系统初始化(0-15 分钟)
1.1 首次登录
使用 DMIT 客户中心提供的 IP 和 root 密码登录:
ssh root@<server_ip>
登录后立即修改 root 密码:
passwd root
1.2 更新系统
apt update && apt upgrade -y # Debian/Ubuntu
yum update -y # CentOS/RHEL
如有内核更新,重启后生效:reboot
1.3 设置时区
timedatectl set-timezone Asia/Shanghai # 或你的时区
timedatectl status
1.4 创建非 root 用户
adduser deploy
usermod -aG sudo deploy
su - deploy # 切换到 deploy 用户测试 sudo 权限
阶段二:安全加固(15-45 分钟)
2.1 配置 SSH Key 登录
在本地生成密钥并上传(详见《SSH 安全加固》):
# 本地执行
ssh-keygen -t ed25519
ssh-copy-id deploy@<server_ip>
2.2 禁用密码登录
# /etc/ssh/sshd_config
PasswordAuthentication no
PermitRootLogin no
systemctl restart sshd
注意:修改后保持当前会话,开新终端测试 Key 登录成功后再关闭。
2.3 配置防火墙
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp # SSH
ufw allow 80/tcp # HTTP
ufw allow 443/tcp # HTTPS
ufw enable
ufw status verbose
如果修改了 SSH 端口,使用新端口替代 22。
2.4 安装 fail2ban
apt install fail2ban -y
systemctl enable fail2ban
systemctl start fail2ban
2.5 配置 IPv6(如需要)
DMIT 默认分配 /64 IPv6 前缀,详细配置见《IPv6 配置教程》。
阶段三:服务部署(45-90 分钟)
3.1 安装 Web 服务器
apt install nginx -y
systemctl enable nginx
systemctl start nginx
验证:curl -I http://localhost 返回 200。
3.2 配置反向代理(可选)
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
3.3 配置 HTTPS
apt install certbot python3-certbot-nginx -y
certbot --nginx -d example.com
3.4 安装数据库(按需)
# PostgreSQL
apt install postgresql -y
systemctl enable postgresql
# MySQL/MariaDB
apt install mariadb-server -y
mysql_secure_installation
阶段四:监控与备份(90-120 分钟)
4.1 基础监控
apt install htop iotop -y
更完善的监控方案见《监控与备份最佳实践》。
4.2 创建 DMIT 快照
在 DMIT 控制面板创建初始快照,作为安全回滚点。命名建议:initial-setup-YYYYMMDD。
4.3 配置自动备份
# /opt/backup.sh
#!/bin/bash
DATE=$(date +%Y%m%d)
tar czf /backup/www-$DATE.tar.gz /var/www/
find /backup -name "*.tar.gz" -mtime +7 -delete
chmod +x /opt/backup.sh
crontab -e
# 添加:0 2 * * * /opt/backup.sh
验证检查清单
| 阶段 | 项目 | 验证方法 |
|---|---|---|
| 初始化 | 系统已更新 | apt list --upgradable 无输出 |
| 初始化 | 时区正确 | timedatectl 显示正确时区 |
| 初始化 | 非 root 用户可用 | su - deploy + sudo 测试 |
| 安全 | SSH Key 登录 | 新终端无需密码登录 |
| 安全 | 密码登录已禁用 | sshd_config PasswordAuthentication no |
| 安全 | 防火墙已启用 | ufw status 显示 active |
| 安全 | fail2ban 运行中 | systemctl status fail2ban |
| 服务 | Web 服务器响应 | curl -I localhost 返回 200 |
| 服务 | HTTPS 已配置 | 浏览器访问 https 无警告 |
| 监控 | 快照已创建 | DMIT 控制面板可见 |
| 监控 | 自动备份已配置 | cron 中可见备份任务 |
后续维护
- 每周检查系统更新:
apt update && apt upgrade - 每月检查磁盘空间:
df -h - 每季度执行恢复演练(见《监控与备份》)
- 定期审查 SSH 配置和防火墙规则
- 关注 DMIT 官方公告,了解机房维护和线路调整
本文核对日期:2026-08-18。操作细节以你的系统版本为准。