争怎路由网/系统工具/内容

ElastaticSearch的版本兼容问题以及处理方案

系统工具2024-06-10 阅读
Linux,全称GNU/Linux,是一种免费使用和自由传播的类UNIX操作系统,其内核由林纳斯·本纳第克特·托瓦兹于1991年10月5日首次发布,它主要受到Minix和Unix思想的启发,是一个基于POSIX的多用户、多任务、支持多线程和多CPU的操作系统。
环境:
Ubuntu:
Linux iZ620vnh79jZ 3.13.0-86-generic #130-Ubuntu SMP Mon Apr 18 18:27:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
 
PHP版本:
PHP 5.5.9-1ubuntu4.21 (cli) (built: Feb9 2017 20:54:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with XCache v3.1.0, Copyright (c) 2005-2013, by mOo
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
with XCache Optimizer v3.1.0, Copyright (c) 2005-2013, by mOo
with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo
with XCache Coverager v3.1.0, Copyright (c) 2005-2013, by mOo
 
Mysql版本:
mysqlVer 14.14 Distrib 5.5.52, for debian-linux-gnu (x86_64) using readline 6.3
 
在搭建ElastaticSearch以后,访问需求端口会出现:
Your version of PHP / json-ext does not support the constant 'JSON_PRESERVE_ZERO_FRACTION',".
" which is important for proper type mapping in Elasticsearch. Please upgrade your PHP or json-ext.\n".
"If you are unable to upgrade, and are willing to accept the consequences, you may use the allowBadJSONSerialization()".
" method on the ClientBuilder to bypass this limitation.
 
这是Elastic的库中出现的问题,对于JSON_PRESERVE_ZERO_FRACTION,该常量是在PHP5.6版本之后才引出来的。所以,此处要写兼容的,解决方案如下:
if(!defined('JSON_PRESERVE_ZERO_FRACTION'))
{
define('JSON_PRESERVE_ZERO_FRACTION', 1024);
}
问题解决!

Linux是一套免费使用和自由传播的类Unix操作系统



……

相关阅读