PDF Print E-mail

Getting json errors on your php site ?

Seeing json_encode or json_decode errors in your Apache logs ?

PHP Fatal error:  Call to undefined function json_decode() in
/var/www/websitename.com/administrator/components/com_zoo/framework/parameter/format/json.php on line 30

Here is how to fix them up.

php 5.0 & php 5.1 don't come with JSON.

It's fairly easy to fix this issue by installing and enabling JSON.

Install JSON with pecl.

# pecl install json

Confirm the module is built.

# ls -la /usr/lib/php/modules/     or
# ls -la /usr/lib64/php/modules/

# ls -la /usr/lib64/php/modules/
total 464
drwxr-xr-x 2 root root   4096 Sep  4 14:04 .
drwxr-xr-x 5 root root   4096 Nov 28  2009 ..
-rwxr-xr-x 1 root root  32344 Apr  7  2009 dbase.so
-rwxr-xr-x 1 root root  92750 Sep  4 14:04 json.so

Build a etc/php.d/json.ini file.

echo "extension=json.so" > /etc/php.d/json.ini
# cat /etc/php.d/json.ini

Restart Apache

/etc/init.d/apache2 configtest
/etc/init.d/apache2 restart

Issues compiling JSON.

No 'make'

Are you seeing this ?

config.status: creating config.h
running: make
sh: make: command not found
ERROR: `make' failed

Check to see if Make is installed

# which make
/usr/bin/which: no make in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

# yum install make

go back to installing json

# pecl install json