Linux 伺服器 中文亂碼問題 終端中文亂碼

2021-07-16 05:11:40 字數 1558 閱讀 8525

一般購買伺服器之後,預設語系是英文。中文會出現亂碼。針對次問題有如下解決方案:

使用local 命令檢視

root@vm-18-12-debian:~# locale

lang=zh_cn.utf-8

language=

lc_ctype=zh_cn.utf-8

lc_numeric="zh_cn.utf-8"

lc_time="zh_cn.utf-8"

lc_collate="zh_cn.utf-8"

lc_monetary="zh_cn.utf-8"

lc_messages="zh_cn.utf-8"

lc_*****="zh_cn.utf-8"

lc_name="zh_cn.utf-8"

lc_address="zh_cn.utf-8"

lc_telephone="zh_cn.utf-8"

lc_measurement="zh_cn.utf-8"

lc_identification="zh_cn.utf-8"

lc_all=

這裡因為我已經修改過了顯示的是中文。

使用 命令:

root@vm-18-12-debian:~# locale -a

cc.utf-8

en_us.utf8

posix

# zh_cn gb2312

# zh_cn.gb18030 gb18030

# zh_cn.gbk gbk

# zh_cn.utf-8 utf-8

# zh_hk big5-hkscs

# zh_hk.utf-8 utf-8

# zh_sg gb2312

# zh_sg.gbk gbk

# zh_sg.utf-8 utf-8

# zh_tw big5

# zh_tw.euc-tw euc-tw

# zh_tw.utf-8 utf-8

# zu_za iso-8859-1

# zu_za.utf-8 utf-8

# en_us.utf-8 utf-8

可以看到中文被注釋了。

把 zh_cn.utf-8 utf-8 去掉注釋。就可以使用中文了。

執行

root@vm-18-12-debian:~# locale-gen

generating locales (this might take a while)...

en_us.utf-8... done

zh_cn.utf-8... done

generation complete.

root@vm-18-12-debian:~# vim /etc/profile
在檔案尾加上

export lang=zh_cn.utf-8
使配置生效:

source /etc/profile

tomcat作為伺服器出現的中文亂碼問題(治標)

當jsp通過form表單提交中文引數時後台發現亂碼。預設情況下,tomcat使用的的編碼方式 iso8859 1 修改tomcat下的conf server.xml檔案 找到如下 這段 規定了tomcat監聽http請求的埠號等資訊。可以在這裡新增乙個屬性 uriencoding,將該屬性值設定為u...

Ubuntu伺服器顯示中文亂碼問題 完美解決

狀況 所用的linux系統不支援中文,遇見中文就zz了。orz 目標 使系統 伺服器支援中文,能夠正常顯示。首先,安裝中文支援包language pack zh hans sudo apt get install language pack zh hans 然後,修改 etc environment...

Ubuntu18 04伺服器的中文亂碼問題

最近伺服器崩潰了,重灌了ubuntu系統,裝完後發現中文字元亂碼,所用的linux系統不支援中文,如下圖所示 首先,安裝中文支援包language pack zh hans sudo apt get install language pack zh hans 然後,修改 etc environmen...