LMLPHP后院

解决Ubuntu cannot change locale (en_US.UTF-8)技术

maybe yes 发表于 2015-03-28 00:50

新买的6刀 VPS 上,每次登录都出现如下警告,编辑文件的中文出现乱码,使用 screen -U 设置编码为 UTF-8 ,依然出现如下警告。

Welcome to Ubuntu 13.10 (GNU/Linux 2.6.32-042stab094.7 x86_64)

 * Documentation:  https://help.ubuntu.com/
Last login: Fri Mar 27 07:19:43 2015 from 101.231.33.158
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

使用 locale 命令,查看错误原因,如下。

root@may:/var/www/WebChat# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

使用 local-gen 安装 en_US 的 locale,解决问题,如下。

root@may:/var/www/WebChat# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
root@may:/var/www/WebChat# locale-gen en_US.UTF-8
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Generating locales...
  en_US.UTF-8... done
Generation complete.
root@may:/var/www/WebChat# locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
相关文章
LMLPHP,可爱滴WEB开发框架

2017-09-23 04:36:48 1506112608 0.006749