zabbix 监控 图形化界面文字乱码解决方法

zabbix安装后之后,很多小伙伴第一时间都是去设置中文界面,发现页面、菜单等可以正常显示中文,但是

唯有图形显示方块,无法正常显示汉字,按照百度教程,上传windows字体,修改配置文件的2处字体配置能解决

按照教程我这里没有解决,最后发现是php编译问题。

参考链接:https://www.linuxidc.com/Linux/2017-12/149284.htm

第一种重新编译安装php,禁用-enable-gd-jis-conv选项,这种方式代价较大;
第二种就是修改zabbix程序代码:

    1、找到include/gaphs-inc.php文件后,在末尾添加如下代码 2、找到该文件中imagettftext()函数(共三处),最后一个参数$string修改为to_entities($string),刷新即可解决问题。

function to_entities($string){
    $len = strlen($string);
    $buf = "";
    for($i = 0; $i < $len; $i++){
        if (ord($string[$i]) <= 127){
            $buf .= $string[$i];
        } else if (ord ($string[$i]) <192){
            //unexpected 2nd, 3rd or 4th byte
            $buf .= "?";
        } else if (ord ($string[$i]) <224){
            //first byte of 2-byte seq
            $buf .= sprintf("&#%d;",
                ((ord($string[$i + 0]) & 31) << 6) +
                (ord($string[$i + 1]) & 63)
            );
            $i += 1;
        } else if (ord ($string[$i]) <240){
            //first byte of 3-byte seq
            $buf .= sprintf("&#%d;",
                ((ord($string[$i + 0]) & 15) << 12) +
                ((ord($string[$i + 1]) & 63) << 6) +
                (ord($string[$i + 2]) & 63)
            );
            $i += 2;
        } else {
            //first byte of 4-byte seq
            $buf .= sprintf("&#%d;",
                ((ord($string[$i + 0]) & 7) << 18) +
                ((ord($string[$i + 1]) & 63) << 12) +
                ((ord($string[$i + 2]) & 63) << 6) +
                (ord($string[$i + 3]) & 63)
            );
            $i += 3;
        }
    }
    return $buf;
}

原文地址:https://www.cnblogs.com/netsa/p/9243581.html