記錄一次cacti中文亂碼解決經過
阿新 • • 發佈:2017-09-21
cacti中文支持 cacti中文亂碼
背景:公司一臺老機器,上面有個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頁面,大功告成,流量圖中已成功顯示中文。
記錄一次cacti中文亂碼解決經過