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"
There is no output, indicating that it is not installed. Enter the following command to install:
yum groupinstall "fonts" -y
The installation is complete, check which Chinese language packs are installed
[root@iz2ze6adlpez0gy7j13vrmz /]# locale -a | grep "zh_CN" zh_CN zh_CN.gb18030 zh_CN.gb2312 zh_CN.gbk zh_CN.utf8
Indicates that the Chinese language pack has been installed on the system and there is no need to install it again. Important note, if your system still cannot use Chinese after following the steps below, please try the above encoding methods one by one. For example, change LANG="zh_CN" to LANG="zh_CN.gb18030".
2 Modify the configuration file
Before modifying the configuration 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 However, the language environment of this machine is not Chinese. You need to modify the locale.conf configuration file
# vim /etc/locale.conf LANG="zh_CN" # source /etc/locale.conf
vim /etc/locale.conf 进入编辑页面,输入i开始编辑,编辑完成输入esc到底行模式,然后输入:wq,保存并退出
You can also use the command to modify the locale.conf configuration file:
# localectl set-locale LANG=zh_CN
Check the current locale afterwards:
# 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
4. Supplementary explanation of the command
locale -a |grep "zh_CN": List the names of all available public locales, and then filter Chinese
locale -a: List the names of all available public language environments.
If you can see the following items, it also means that the system has installed the Chinese language pack. No need to install anymore, so what do these items mean?
##{Language code}_{Country code}.{Character set}
zh is Chinese The code name, CN is the code name of China, gb18030, gb2312, utf8 is the language character set
Then each item can be commonly understood as "You speak Chinese, you are in China, language The character set is gb18030/gb2312/utf8”
If the above items are not found, manually install the Chinese language pack
# yum install kde -l10n-Chinese (about 11M)
locale: View the current system language environment
LANG: The language of the current system
LC_CTYPE: Language symbols and their classification
LC_NUMERIC: Numbers
LC_COLLATE: Comparison and sorting habits
LC_TIME: Time display format
LC_MONETARY: Currency unit
LC_MESSAGES: Information mainly includes prompt information, error information, status information, titles, labels, buttons and menus, etc.
LC_NAME: Name writing method
LC_ADDRESS:Address writing method
LC_TELEPHONE:Phone number writing method
LC_MEASUREMENT:Weights and measures expression
LC_PAPER: Default paper size
LC_IDENTIFICATION: Overview of the information contained in the locale itself
LC_ALL: The variable with the highest priority. If this variable is set, all LC_* and LANG variables will be forced to follow its value
Restart the system
# reboot
5. Solve the garbled problem of remote tool SSH Secure
Use remote tools When connecting, if Linux has Chinese files or directories, garbled characters will appear during display. The reason is that the Linux encoding is UTF-8, and the remote tool defaults to the current system local encoding, which is GBK. So the solution is to unify the encoding of both. However, the SSH Secure tool cannot set the encoding, so the encoding is unified by modifying the system encoding of Linux.
Step one: Check the locale of the current system.
Step 2: Modify the configuration file locale.conf
# vim /etc/locale.confEnter i to enter the editing mode. After editing, press ESC to enter the bottom line mode. Then enter: wq to exit and save.
执行下面的命令,让修改生效。
# source /etc/locale.conf
输入date验证。如果还有问题,也可以reboot重启一下。
推荐教程: 《CentOS教程》
The above is the detailed content of How to solve the Chinese garbled problem in centos7. For more information, please follow other related articles on the PHP Chinese website!

CentOS is suitable for building powerful and reliable servers. Its advantages include: 1. Stability and reliability, support cycle up to 10 years; 2. Security, built-in SELinux and regular security patches; 3. Compatibility and ecosystem, highly compatible with RHEL, with a rich software warehouse; 4. Performance optimization, suitable for various hardware platforms and providing kernel tuning.

CentOS will continue to evolve in the future, and users should choose alternative distributions. 1) Evaluate the requirements, choose such as RockyLinux or AlmaLinux, and focus on stability and support. 2) Develop a migration plan, use tools such as CentOS2Rocky, and pay attention to testing and verification. 3) Plan early, maintain contact with the open source community, and ensure a smooth transition.

CentOS is widely selected as a server operating system because it is stable, secure and free. 1.CentOS is based on RHEL, providing enterprise-level stability and a life cycle of up to 10 years. 2. It has rich software packages and strong community support. 3. Simple installation, use yum management software package, and intuitive configuration. 4. Improve server management efficiency through command line tools, regular backups and log management. 5. Optimize server performance by adjusting kernel and network parameters.

CentOS will continue to develop through CentOSStream in the future. CentOSStream is no longer a direct clone of RHEL, but is part of RHEL development. Users can experience the new RHEL functions in advance and participate in development.

The transition from development to production in CentOS can be achieved through the following steps: 1. Ensure the consistent development and production environment, use the YUM package management system; 2. Use Git for version control; 3. Use Ansible and other tools to automatically deploy; 4. Use Docker for environmental isolation. Through these methods, CentOS provides powerful support from development to production, ensuring the stable operation of applications in different environments.

CentOSStream is a cutting-edge version of RHEL, providing an open platform for users to experience the new RHEL functions in advance. 1.CentOSStream is the upstream development and testing environment of RHEL, connecting RHEL and Fedora. 2. Through rolling releases, users can continuously receive updates, but they need to pay attention to stability. 3. The basic usage is similar to traditional CentOS and needs to be updated frequently; advanced usage can be used to develop new functions. 4. Frequently asked questions include package compatibility and configuration file changes, and requires debugging using dnf and diff. 5. Performance optimization suggestions include regular cleaning of the system, optimizing update policies and monitoring system performance.

The reason for the end of CentOS is RedHat's business strategy adjustment, community-business balance and market competition. Specifically manifested as: 1. RedHat accelerates the RHEL development cycle through CentOSStream and attracts more users to participate in the RHEL ecosystem. 2. RedHat needs to find a balance between supporting open source communities and promoting commercial products, and CentOSStream can better convert community contributions into RHEL improvements. 3. Faced with fierce competition in the Linux market, RedHat needs new strategies to maintain its leading position in the enterprise-level market.

RedHat shut down CentOS8.x and launches CentOSStream because it hopes to provide a platform closer to the RHEL development cycle through the latter. 1. CentOSStream, as the upstream development platform of RHEL, adopts a rolling release mode. 2. This transformation aims to enable the community to get exposure to new RHEL features earlier and provide feedback to accelerate the RHEL development cycle. 3. Users need to adapt to changing systems and reevaluate system requirements and migration strategies.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools
