背景:公司一台老机器,上面有个cacti。系统为centos5.X,有天手滑卸载了httpd,但yum源已经不支持centos5系列了,无奈百度上找了一个源内容如下:
<span style="background-color: rgb(255, 102, 102);"><strong><span style="color:#ff6666;"># CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://vault.centos.org/5.11/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=http://vault.centos.org/5.11/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=http://vault.centos.org/5.11/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl=http://vault.centos.org/5.11/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ baseurl=http://vault.centos.org/5.11/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5</span></strong></span>
装上后发现原本有中文支持的cacti图片全部不显示中文了,百度上找了一圈。全是说要么重新编译rrdtool,要么修改src/cacti/lib/function.php加入setlocale(LC_CTYPE,"zh_CN.UTF-8");之类的全部试遍了还是乱码,最后google到一篇文章,参考其思路解决问题。https://www.iyunv.com/thread-366540-1-1.html
检查httpd/conf/httpd.conf中发现已有AddDefaultCharset GB2312,且cacti的grph栏中可以正常显示中文,编码格式确定。
检查/etc/sysconfig/httpd文件中发现HTTPD_LANG行为注销状态,取消此行前面的#号,修改为HTTPD_LANG=zh_CN.gb2312。
保存,重启httpd,刷新cacti页面,大功告成,流量图中已成功显示中文。
原文地址:http://chenshunde.blog.51cto.com/707114/1967289