0 系統(tǒng)環(huán)境
CentOS 7.4
# rpm -q centos-release
centos-release-7-4.1708.el7.centos.x86_64
1 問題
初裝的系統(tǒng)政溃,如果輸入 locale 查看系統(tǒng)字體編碼,可能會(huì)出現(xiàn)報(bào)錯(cuò)
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
或者設(shè)置編碼不完全時(shí)态秧,會(huì)出現(xiàn)警告
LC_CTYPE: cannot change locale (UTF-8): No such file or directory
2 解決方法
如果要設(shè)置中文版的字體編碼董虱。在每個(gè)文件中增加以下內(nèi)容。
中文版
# vim /etc/profile.d/locale.sh
export LC_CTYPE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
# vim /etc/locale.conf
LANG=zh_CN.UTF-8
# vim /etc/sysconfig/i18n
LANG=zh_CN.UTF-8
# vim /etc/environment
LANG=zh_CN.UTF-8
LC_ALL=zh_CN.UTF-8
英文版本
# vim /etc/profile.d/locale.sh
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# vim /etc/locale.conf
LANG=en_US.UTF-8
# vim /etc/sysconfig/i18n
LANG=en_US.UTF-8
# vim /etc/environment
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
3 參考
CentOS7 LC_CTYPE: cannot change locale (UTF-8): No such file or directory
CentOS cannot change locale UTF-8解決方法及設(shè)置中文支持