{"id":162,"date":"2022-01-07T02:42:44","date_gmt":"2022-01-07T02:42:44","guid":{"rendered":"https:\/\/focalx.com\/blog\/?p=162"},"modified":"2022-01-07T05:15:23","modified_gmt":"2022-01-07T05:15:23","slug":"php-json_encode-and-json_decode-functions-are-missing-in-rhel-8","status":"publish","type":"post","link":"https:\/\/focalx.com\/blog\/2022\/01\/php-json_encode-and-json_decode-functions-are-missing-in-rhel-8\/","title":{"rendered":"PHP json_encode() and json_decode() functions missing in RHEL 8"},"content":{"rendered":"\n<p>If you have just set up a RHEL 8 server, this includes CentOS 8, AlmaLinux 8, and Rocky Linux 8, you might have run into a fatal PHP error when using JSON related functions. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> PHP Fatal error:  Uncaught Error: Call to undefined function json_encode()<\/code><\/pre>\n\n\n\n<p>This is because in RHEL 8, standard PHP installation is no longer including JSON support, which is different when you installed PHP in RHEL 6 or 7.<\/p>\n\n\n\n<p>The solution is very simple. Just install the PHP JSON support separately. Run this as <em>root<\/em> using <em>yum<\/em> or <em>dnf<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> dnf install php-json<\/code><\/pre>\n\n\n\n<p>Remember to restart your web server (e.g. Apache, Nginx, etc).<\/p>\n\n\n\n<p>Running <em>phpinfo()<\/em>, you should see a JSON section indicating &#8220;json support: enabled&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"315\" src=\"https:\/\/focalx.com\/blog\/wp-content\/uploads\/2022\/01\/image-1-1024x315.png\" alt=\"\" class=\"wp-image-164\" srcset=\"https:\/\/focalx.com\/blog\/wp-content\/uploads\/2022\/01\/image-1-1024x315.png 1024w, https:\/\/focalx.com\/blog\/wp-content\/uploads\/2022\/01\/image-1-300x92.png 300w, https:\/\/focalx.com\/blog\/wp-content\/uploads\/2022\/01\/image-1-768x236.png 768w, https:\/\/focalx.com\/blog\/wp-content\/uploads\/2022\/01\/image-1.png 1092w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now, you should be able to use JSON related functions like <em>json_encode()<\/em> and <em>json_decode()<\/em>. \u00a0If you have any questions, please do not hesitate to contact me at\u00a0<a rel=\"noreferrer noopener\" href=\"mailto:info@focalx.com\" target=\"_blank\">info@focalx.com<\/a>, and I am happy to discussion with you further.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have just set up a RHEL 8 server, this includes CentOS 8, AlmaLinux 8, and Rocky Linux 8, you might have run into a fatal PHP error when using JSON related functions. For example: This is because in RHEL 8, standard PHP installation is no longer including JSON [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":44,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[26],"tags":[3,32,30,31],"_links":{"self":[{"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/posts\/162"}],"collection":[{"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":3,"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":169,"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/posts\/162\/revisions\/169"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/media\/44"}],"wp:attachment":[{"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/focalx.com\/blog\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}