下面以 CentOS 7 / 8 / Stream(Minimal 安装) 为例,给你一套从安装后到可用的最小配置清单,适合服务器/虚拟机环境。
Minimal 安装 默认网络通常是关闭的
ip addr
一般是:ens33 / eth0
vi /etc/sysconfig/network-scripts/ifcfg-ens33
修改或确认:
BOOTPROTO=dhcp
ONBOOT=yes
重启网络:
systemctl restart network
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=114.114.114.114
重启网络:
systemctl restart network
验证:
ip addr
ping -c 3 www.baidu.com
yum update -y
或(CentOS 8 / Stream):
dnf update -y
yum install -y \
vim \
wget \
curl \
net-tools \
bash-completion \
lrzsz \
tree
常用说明:
net-tools:ifconfig、netstatbash-completion:命令自动补全lrzsz:rz / sz 上传下载hostnamectl set-hostname server01
查看:
hostname
vim /etc/ssh/sshd_config
确认或修改为:
PermitRootLogin yes
重启 SSH:
systemctl restart sshd
UseDNS no
vim /etc/selinux/config
修改为:
SELINUX=disabled
重启生效:
reboot
临时关闭(不重启):
setenforce 0
systemctl status firewalld
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload
systemctl stop firewalld
systemctl disable firewalld
timedatectl set-timezone Asia/Shanghai
确认:
timedatectl
useradd admin
passwd admin
赋予 sudo 权限:
echo "admin ALL=(ALL) ALL" >> /etc/sudoers
vim /etc/security/limits.conf
添加:
* soft nofile 65535
* hard nofile 65535
systemctl disable postfix
CentOS 8 官方源已停止维护,需换源:
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
| 项目 | 是否必做 |
|---|---|
| 网络配置 | ✅ |
| 更新系统 | ✅ |
| 安装基础工具 | ✅ |
| SSH 设置 | ✅ |
| SELinux | ✅ |
| 时区 | ✅ |
如果你告诉我:
我可以给你一套更精确、更精简的配置方案。