Debian服务器Perl本地化设置失败

我们安装Debian或Ubuntu时,可能本地化设置(locale)并不完整。所以安装Perl应用程序时会警告本地化设置失败。你可能会看到如下警告信息:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_TIME = "zh_CN.UTF-8",
        LC_MONETARY = "zh_CN.UTF-8",
        LC_ADDRESS = "zh_CN.UTF-8",
        LC_TELEPHONE = "zh_CN.UTF-8",
        LC_NAME = "zh_CN.UTF-8",
        LC_MEASUREMENT = "zh_CN.UTF-8",
        LC_IDENTIFICATION = "zh_CN.UTF-8",
        LC_NUMERIC = "zh_CN.UTF-8",
        LC_PAPER = "zh_CN.UTF-8",
        LANG = "en_US.UTF-8"
        are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
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

在这种情况下,我们不能在终端中使用中文。

解决方法

我们可以输入下面的命令来生成未安装的locales

sudo dpkg-reconfigure locales

这条命令会打开一个对话框,要你选择locales。我们要把en_US.UTF-8和所有的简体中文locales都选上。如下,按空格键来选择,有*号表示选择上了。选择完locales后,按Enter键确认。

Selection_041然后,选择默认的locale,我们可以选择zh_CN.UTF-8

Selection_042

确认OK后,locale的问题就解决了!我们可以在终端中使用中文了。

如果你的终端没有出现一个对话框,那么先要输入下面的命令来安装 dialog
sudo apt-get install dialog

为这篇文章评分
[Total: 1 Average: 4]

Leave a Reply

Your email address will not be published.

The maximum upload file size: 2 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here