配置 Linux 服务器是一个比较宽泛的话题,具体步骤取决于你用什么发行版(如 Ubuntu、CentOS、Debian)以及服务器用途(Web 服务器、数据库、开发环境等)。
下面我给你一个通用、实用的 Linux 服务器基础配置流程,适合新手和常见生产环境。
ssh root@服务器IP
# Ubuntu / Debian
apt update && apt upgrade -y
# CentOS / Rocky
dnf update -y
adduser deploy
usermod -aG sudo deploy # Ubuntu
# CentOS 用 wheel 组
编辑配置文件:
vim /etc/ssh/sshd_config
建议修改:
PermitRootLogin no
PasswordAuthentication no
然后重启:
systemctl restart sshd
# Ubuntu
ufw allow 22
ufw allow 80
ufw allow 443
ufw enable
# CentOS
firewall-cmd --add-service=ssh --permanent
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
apt install -y curl wget git vim unzip
timedatectl set-timezone Asia/Shanghai
apt install nginx -y
systemctl enable nginx
curl -fsSL https://get.docker.com | sh
systemctl enable docker
systemctl disable bluetooth
apt install fail2ban -y
htop 查看资源journalctl 查看日志df -h 查看磁盘✅ 非 root 用户
✅ SSH 密钥登录
✅ 防火墙开启
✅ Nginx + 域名
✅ 自动更新或定期更新
如果你能告诉我:
我可以给你更精确的一步一步配置方案。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。