linux網頁顯示亂碼終極解決---達到英文全部顯示為中文

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

遇到問題:本想在自己機器上的虛擬機上下載安裝個redmine,體驗項目管理軟體,結果打開百度,才發現全部都顯示未為亂碼,於是嘗試了好些辦法,終於有了一個清晰的思路:一.安裝好網路yum,二.安裝rpm包,修改配置參數.亂碼如下圖:

解決問題:

一,安裝網路yum,即可以使yum安裝時,在互聯網中尋找包.

1.把mirrors-rpmforge,rhel-debuginfo.repo,rpmforge.repo這三個文件複製到/etc/yum.repos.d目錄下.(直接把這三個文件複製到/etc/yum.repos.d目錄下)

vi mirrors-rpmforge

  1. http://apt.sw.be/redhat/el5/en/$ARCH/dag
  2. http://archive.cs.uu.nl/mirror/dag.wieers/redhat/el5/en/$ARCH/dag
  3. http://ftp2.lcpe.uni-sofia.bg/freshrpms/pub/dag/redhat/el5/en/$ARCH/dag
  4. #http://ftp.heanet.ie/pub/freshrpms/pub/dag/redhat/el5/en/$ARCH/dag
  5. http://ftp-stud.fht-esslingen.de/dag/redhat/el5/en/$ARCH/dag
  6. http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el5/en/$ARCH/dag
  7. http://mirrors.ircam.fr/pub/dag/redhat/el5/en/$ARCH/dag
  8. http://rh-mirror.linux.iastate.edu/pub/dag/redhat/el5/en/$ARCH/dag
  9. http://rpmfind.net/linux/dag/redhat/el5/en/$ARCH/dag
  10. http://wftp.tu-chemnitz.de/pub/linux/dag/redhat/el5/en/$ARCH/dag
  11. http://www.mirrorservice.org/sites/apt.sw.be/redhat/el5/en/$ARCH/dag

vi rhel-debuginfo.repo

  1. [base]

  2. name=CentOS-5 - Base
  3. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&
  4. repo=os
  5. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
  6. baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
  7. gpgcheck=1
  8. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
  9. #released updates
  10. [update]
  11. name=CentOS-5 - Updates
  12. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
  13. baseurl

    =http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
  14. gpgcheck=1
  15. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
  16. #packages used/produced in the build but not released
  17. [addons]
  18. name=CentOS-5 - Addons
  19. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
  20. baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
  21. gpgcheck=1

vi rpmforge.repo

  1. # Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
  2. # URL: http://rpmforge.net/
  3. [rpmforge]
  4. name = Red Hat Enterprise $releasever - RPMforge.net - dag

  5. #baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
  6. mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
  7. #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
  8. enabled = 1
  9. protect = 0
  10. gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
  11. gpgcheck = 1

2.http://rpmfind.net/linux/RPM/dag/redhat/el5/i386/rpmforge-release-0.3.6-1.el5.rf.i386.html下載到

rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

3.把yum的自動更新關掉:rm -f /var/run/yum.pid

為了防止舊版本的GPG keys 造成錯誤,在命令行輸入rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-Centos-5(在命令行輸入,就不要下劃線了,然後就是這個命令有時運行不成功,那就多運行幾次,就成功了,我也不知道這是為什麼)

到這裡網路yum搭建完畢,在來配置第二部分:如何不導致亂碼

1.在終端輸入:yum -y install fonts-chinese

2.

在網上下載2個中文包(有關rpm包都可以在http://rpm.pbone.net中搜索並下載到)

http://rpm.pbone.net/index.php3

然後rpm -ivh xxxx(上面2個包的全名)

3.vi /etc/sysconfig/i18n修改為

  1. LANG="zh_CN.GB18030"
  2. LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
  3. SUPPORTED="zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en"
  4. SYSFONT="lat0-sun16"

4.yum安裝中文字體

yum -y install fonts-chinese.noarch (需要等待安裝一段時間,)

重啟,之後登陸系統,會發現所有界面從英文變成 中文(很歡喜).





[火星人 ] linux網頁顯示亂碼終極解決---達到英文全部顯示為中文已經有443次圍觀

http://coctec.com/docs/linux/show-post-47571.html