一键脚本支持:Debian 8/9Ubuntu 14/16CentOS 6/7
脚本在Digital Ocean谷歌云GCP阿里云测试成功
GitHub:https://github.com/FunctionClub/LocaleCN
除了一键脚本也可以手动安装中文语言包;
- wget -N --no-check-certificate https://raw.githubusercontent.com/FunctionClub/LocaleCN/master/LocaleCN.sh && bash LocaleCN.sh
脚本运行完毕后重启VPS即可生效
- Reading package lists... Done
- Building dependency tree
- Reading state information... Done
- gawk is already the newest version (1:4.1.3+dfsg-0.1).
- xz-utils is already the newest version (5.1.1alpha+20120614-2ubuntu2).
- file is already the newest version (1:5.25-2ubuntu1.2).
- openssl is already the newest version (1.0.2g-1ubuntu4.15).
- 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
- 正在读取软件包列表... 完成
- 正在分析软件包的依赖关系树
- 正在读取状态信息... 完成
- gawk 已经是最新版 (1:4.1.3+dfsg-0.1)。
- xz-utils 已经是最新版 (5.1.1alpha+20120614-2ubuntu2)。
- file 已经是最新版 (1:5.25-2ubuntu1.2)。
- openssl 已经是最新版 (1.0.2g-1ubuntu4.15)。
- 升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 7 个软件包未被升级
首先适用locale -a命令查看是否有中文语言包zh_CN.utf8如果没有可以使用以下命令安装中文语言包,如果有就直接修改配置文件参数即可;
安装中文语言包
通过locale -a命令查看是否下载完毕
修改配置文件参数
- vi /etc/default/locale
-
- # 修改内容如下:
- LANG="zh_CN.utf8"
- LANGUAGE="zh_CN:zh"
- LC_ALL="zh_CN.utf8"
-
- # 或者
- LANG=zh_CN.UTF-8
- LANGUAGE="zh_CN.UTF-8"
- LC_CTYPE="zh_CN.UTF-8"
- LC_NUMERIC="zh_CN.UTF-8"
- LC_TIME="zh_CN.UTF-8"
- LC_COLLATE="zh_CN.UTF-8"
- LC_MONETARY="zh_CN.UTF-8"
- LC_MESSAGES="zh_CN.UTF-8"
- LC_PAPER="zh_CN.UTF-8"
- LC_NAME="zh_CN.UTF-8"
- LC_ADDRESS="zh_CN.UTF-8"
- LC_TELEPHONE="zh_CN.UTF-8"
- LC_MEASUREMENT="zh_CN.UTF-8"
- LC_IDENTIFICATION="zh_CN.UTF-8"
- LC_ALL="zh_CN.UTF-8"
- # CentOS 6.5
- vi /etc/sysconfig/i18n
- # CentOS 7
- vi /etc/locale.conf
-
- # 修改内容如下:
- LANG=zh_CN.UTF-8
配置文件修改完成后保存退出,然后reboot重启机器使其生效即可;