前提
VirtualBox-7.2.2已安装
CentOS-Stream-9 最小化安装:https://mirrors.tuna.tsinghua.edu.cn/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso
注:CentOS-Stream-9选择最小的boot镜像就可以了,安装过程中选择最小化安装
VirtualBox设置网络模式为桥接模式
基础系统配置
远程root登录
# 编辑 ssh 配置
vim /etc/ssh/sshd_config
# /etc/ssh/sshd_config修改内容:
PermitRootLogin yes # 允许 root 远程登录
# 重启ssh服务
systemctl restart sshd
# 关闭防火墙,注意本地实验环境可以这么做,生成环境不要这么做
systemctl stop firewalld
systemctl disable firewalld
# 查看IP
ip addr
后面就可以使用远程连接22端口进行远程登录操作了
更新系统
dnf update -y
dnf install epel-release -y
dnf update -y
安装常用软件
# 安装常用工具
dnf install -y wget curl vim net-tools unzip bash-completion git
# 安装常用开发工具(如需要编译 C/C++)
dnf groupinstall "Development Tools" -y
YUM 源替换成阿里云源
cd /etc/yum.repos.d && mkdir -p backup && mv *.repo backup/
cat << EOF > aliyun.repo
[baseos]
name=CentOS Stream 9 - BaseOS
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos-stream/9-stream/RPM-GPG-KEY-CentOS-Official
[appstream]
name=CentOS Stream 9 - AppStream
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/AppStream/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos-stream/9-stream/RPM-GPG-KEY-CentOS-Official
EOF
dnf clean all
dnf makecache
时区设置
# 设置时区为中国
timedatectl set-timezone Asia/Shanghai
# 开启时间同步
timedatectl set-ntp true
新增非root用户
# 创建用户
useradd demo
passwd demo
# 添加到 wheel 组获取 sudo 权限
usermod -aG wheel demo
总结
最小化安装结合基础系统配置,就可以得到一个很小的比较纯净测试环境了。
tips:配置完基础系统之后,记得使用VirtualBox生成一个系统快照,这样以后就想要恢复就很方便了。