linux网页显示乱码终极解决---达到英文全部显示为中文
2012-03-07 16:05:21
版权声明:原创作品,如需转载,请与作者联系。否则将追究法律责任。
遇到问题:本想在自己机器上的虚拟机上下载安装个redmine,体验项目管理软件,结果打开百度,才发现全部都显示未为乱码,于是尝试了好些办法,终于有了一个清晰的思路:一。安装好网络yum,二。安装rpm包,修改配置参数。乱码如下图:
解决问题:
一,安装网络yum,即可以使yum安装时,在互联网中寻找包。
1.把mirrors-rpmforge,rhel-debuginfo.repo,rpmforge.repo这三个文件复制到/etc/yum.repos.d目录下。(直接把这三个文件复制到/etc/yum.repos.d目录下)
vi mirrors-rpmforge
http://apt.sw.be/redhat/el5/en/$ARCH/dag http://archive.cs.uu.nl/mirror/dag.wieers/redhat/el5/en/$ARCH/dag http://ftp2.lcpe.uni-sofia.bg/freshrpms/pub/dag/redhat/el5/en/$ARCH/dag #http://ftp.heanet.ie/pub/freshrpms/pub/dag/redhat/el5/en/$ARCH/dag http://ftp-stud.fht-esslingen.de/dag/redhat/el5/en/$ARCH/dag http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el5/en/$ARCH/dag http://mirrors.ircam.fr/pub/dag/redhat/el5/en/$ARCH/dag http://rh-mirror.linux.iastate.edu/pub/dag/redhat/el5/en/$ARCH/dag http://rpmfind.net/linux/dag/redhat/el5/en/$ARCH/dag http://wftp.tu-chemnitz.de/pub/linux/dag/redhat/el5/en/$ARCH/dag http://www.mirrorservice.org/sites/apt.sw.be/redhat/el5/en/$ARCH/dag
vi rhel-debuginfo.repo
[base] name=CentOS-5 - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch& repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #released updates [update] name=CentOS-5 - Updates #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5 #packages used/produced in the build but not released [addons] name=CentOS-5 - Addons #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/ gpgcheck=1
vi rpmforge.repo
# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag # URL: http://rpmforge.net/ [rpmforge] name = Red Hat Enterprise $releasever - RPMforge.net - dag #baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge enabled = 1 protect = 0 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag 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修改为
LANG="zh_CN.GB18030" LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN" SUPPORTED="zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en" SYSFONT="lat0-sun16"
4.yum安装中文字体
yum -y install fonts-chinese.noarch (需要等待安装一段时间,)
重启,之后登陆系统,会发现所有界面从英文变成 中文(很欢喜)。