Home>Article>Operation and Maintenance> How to solve the problem of Chinese garbled characters under centos7

How to solve the problem of Chinese garbled characters under centos7

王林
王林 Original
2020-04-01 11:05:36 9282browse

How to solve the problem of Chinese garbled characters under centos7

1. Check whether the Chinese package is installed

You can use the following naming to check whether the Chinese installation package is installed on the system.

locale -a |grep "zh_CN"

How to solve the problem of Chinese garbled characters under centos7

There is no output, indicating that it is not installed. Enter the following command to install:

yum groupinstall "fonts" -y

2. Modify the configuration file

After modifying the configuration Before file, let’s take a look at the current system language environment:

# echo $LANG en_US.UTF-8 # locale LANG=en_US.UTF-8 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=

Although the Chinese language pack is installed, the locale of this machine is not Chinese, and the locale.conf configuration file needs to be modified.

# vim /etc/locale.conf LANG="zh_CN" # source /etc/locale.conf

vim /etc/locale.conf Enter the editing page, enter i to start editing, enter esc to enter bottom line mode after editing, then enter: wq, save and exit.

Then check the current locale:

# echo $LANG zh_CN # locale LANG=zh_CN LC_CTYPE="zh_CN" LC_NUMERIC="zh_CN" LC_TIME="zh_CN" LC_COLLATE="zh_CN" LC_MONETARY="zh_CN" LC_MESSAGES="zh_CN" LC_PAPER="zh_CN" LC_NAME="zh_CN" LC_ADDRESS="zh_CN" LC_TELEPHONE="zh_CN" LC_MEASUREMENT="zh_CN" LC_IDENTIFICATION="zh_CN" LC_ALL=

3. Verification is successful

[root@node2 ~]# date 2017年 10月 16日 星期一 16:30:24 CST

Recommended related tutorials:centos tutorial

The above is the detailed content of How to solve the problem of Chinese garbled characters under centos7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn