Исправляем ошибку ru_RU локалей на ubuntu-сервере

После установки «идеального сервера» могут появиться предупреждения об ошибках русских локалей:

-bash: warning: setlocale: LC_ALL: cannot change locale (ru_RU.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (ru_RU.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (ru_RU.UTF-8)
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (ru_RU.UTF-8)

Проверить, правильно ли у нас сконфигурированы локали можно запросив версию какого либо пакета, установленного в системе, например:

# perl -v

Вывод результата должен быть без ошибок и предупреждений, примерно такой:

# perl -v

This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi
(with 41 registered patches, see perl -V for more detail)

Copyright 1987-2013, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Если же система сообщает примерно такое:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = "ru_RU.UTF-8",
LC_NUMERIC = "POSIX",
LC_MESSAGES = "POSIX",
LC_TIME = "POSIX",
LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

значит надо переконфигурировать locale.

Выполняем:

sudo locale-gen en_US en_US.UTF-8 ru_RU.UTF-8

и

sudo dpkg-reconfigure locales

Проверяем:

# perl -v

This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi
(with 41 registered patches, see perl -V for more detail)

Copyright 1987-2013, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Всё, ошибок больше нет.

Добавить комментарий