[ZBX-16775] Zabbix needs php-json (and is not installed) in zabbix official repository (at least in CentOS 8.x) Created: 2019 Oct 15  Updated: 2020 Aug 25  Resolved: 2020 Aug 25

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 4.4.0
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: André Pereira da Silva Assignee: Kristians Pavars
Resolution: Won't fix Votes: 0
Labels: CentOS, Frontend, JSON, PHP
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOS 8.x



 Description   

After installing zabbix from zabbix repository and making some monitoring i start to get some errors in php error log.

After investigation the issue is php-json package is not installed when installing from zabbix offical repository. Manually installing php-json solves the issue.
https://www.zabbix.com/download?zabbix=4.4&os_distribution=centos&os_version=8&db=mysql

PHP Fatal error: Uncaught Error: *Call to undefined function json_encode() in /usr/share/zabbix/include/func.inc.php:1833*
 Stack trace:
 #0 /usr/share/zabbix/include/classes/mvc/CController.php(330): access_deny(1)
 #1 /usr/share/zabbix/include/classes/core/ZBase.php(392): CController->run()
 #2 /usr/share/zabbix/include/classes/core/ZBase.php(158): ZBase->processRequest(Object(CRouter))
 #3 /usr/share/zabbix/include/config.inc.php(33): ZBase->run('default')
 #4 /usr/share/zabbix/zabbix.php(21): require_once('/usr/share/zabb...')

Also, if php json extension is needed, IMHO it should be listed as a requirement in zabbix install page (as are others required php extensions).



 Comments   
Comment by Arturs Lontons [ 2019 Oct 16 ]

Hi,

Have you made any specific changes to the configuration after which the issue was detected? Simply installing the packages on Centos 8 does not seem to produce the error message described in the bug report.

Regards,
Arurs.

Comment by Edgar Akhmetshin [ 2019 Oct 17 ]

Hi,

Could you also please clarify repository list used (all enabled repo) for the system during Zabbix installation?

Regards,
Edgar

Comment by André Pereira da Silva [ 2019 Oct 20 ]

Only used zabbix offical repository, all others are CentOS official repos + epel.

https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm

I don't know what particulary steps i made. using zabbix 4.4 for 2 weeks until noticed that error in the log, installed php-json extension (dnf install php-json, restarted php-fpm service and no more error). This is in a brand new CentOS 8.x installation.

Anyway having PHP function "json_encode" (https://www.php.net/manual/en/function.json-encode.php) in zabbix web frontend code (as you see above in the stack trace and in https://github.com/zabbix/zabbix/blob/master/frontends/php/include/func.inc.php#L1813) means the php-json extension is needed (or will give that error in some circumstance), so that extension should a dependency on install.

 

Comment by Kristians Pavars [ 2020 Aug 25 ]

Hi andre.silva,

 

Not sure how you ran into this error. Doing a fresh install of zabbix-web-mysql Zabbix 4.4.9 on Centos 8 installs php-json as dependency:

[kp@centos8 ~]$ sudo dnf install zabbix-web-mysql
Last metadata expiration check: 0:08:22 ago on Tue Aug 25 10:01:33 2020.
Dependencies resolved.
======================================================================================================================== Package                      Architecture    Version                                          Repository          Size
========================================================================================================================Installing:
 zabbix-web-mysql             noarch          4.4.10-1.el8                                     zabbix              15 k
Installing dependencies:
 dejavu-fonts-common          noarch          2.35-6.el8                                       BaseOS              74 k
 dejavu-sans-fonts            noarch          2.35-6.el8                                       BaseOS             1.5 M
 httpd-filesystem             noarch          2.4.37-21.module_el8.2.0+382+15b0afa8            AppStream           36 k
 nginx-filesystem             noarch          1:1.14.1-9.module_el8.0.0+184+e34fea82           AppStream           24 k
 php-bcmath                   x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream           79 k
 php-common                   x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream          661 k
 php-fpm                      x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream          1.6 M
 php-gd                       x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream           84 k
 php-json                     x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream           73 k
 php-ldap                     x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream           79 k
 php-mbstring                 x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream          580 k
 php-mysqlnd                  x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream          190 k
 php-pdo                      x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream          122 k
 php-xml                      x86_64          7.2.24-1.module_el8.2.0+313+b04d0a66             AppStream          188 k
 zabbix-web                   noarch          4.4.10-1.el8                                     zabbix             2.9 M
Enabling module streams:
 httpd                                        2.4
 nginx                                        1.14
 php                                          7.2Transaction Summary
========================================================================================================================Install  16 PackagesTotal download size: 8.2 M
Installed size: 37 M
Is this ok [y/N]:y

I will close this ticket as there seems to be no issue here but a one-off.

 

Regards,
Kristiāns

 

Generated at Mon Apr 28 11:02:31 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.