在 CentOS Minimal(最小化安装) 中默认是没有中文语言包和中文环境的,需要手动安装和配置。下面按 CentOS 7 / 8 / Stream 通用流程说明(以 CentOS 7 为例,其他版本差异会注明)。
locale
如果看到:
LANG=en_US.UTF-8
说明当前是英文环境。
yum install -y langpacks-zh_CN
如果是 CentOS 8 / Stream:
dnf install -y langpacks-zh_CN
localectllocalectl set-locale LANG=zh_CN.UTF-8
立即生效(或重启):
reboot
编辑配置文件:
vi /etc/locale.conf
修改为:
LANG="zh_CN.UTF-8"
保存后执行:
source /etc/locale.conf
或重启系统。
locale
应看到:
LANG=zh_CN.UTF-8
再执行:
date
如果显示:
2026年 01月 15日 星期四
说明中文环境已生效。
"font": { "face": "Microsoft YaHei" }
yum install -y wqy-zenhei-fonts
可能是 未安装语言包,重新执行:
yum install -y langpacks-zh_CN
| 项目 | CentOS 7 | CentOS 8 / Stream |
|---|---|---|
| 包管理 | yum | dnf |
| 语言包 | langpacks-zh_CN | 相同 |
yum install -y langpacks-zh_CN
localectl set-locale LANG=zh_CN.UTF-8
reboot
如果你告诉我:
我可以给你 更精确的一步到位方案。