JSON on RHEL & PHP 5.1.6

Stuck with PHP 5.1.6 on RHEL or even CentOS (and a sysadmin who insists on using packages)? Need JSON? I did. The solution is easy:

yum install php-devel
pecl install json

The pecl install failed when it hit an 8MB memory limit, and I was clueless about how to fix it until I learned that the pecl installer ignores the php.ini. Turns out the best solution is to use the pear installer (which does follow php.ini settings):

pear install pecl/json

15 Responses to “JSON on RHEL & PHP 5.1.6”

  1. I paul hereby apply to ur company i am a native of nigeria.i was born in_ 1980 in ondo

  2. Thanks man. This really helped.

  3. I was migrating a CakePHP site to Rackspace’s Cloud server and ran into this issue. No repository had it so it was the pecl install for me. Worked like a charm.

  4. I am having the trouble with JSON and PHP as well.

    I have followed all the steps; running php -r ‘var_dump(function_exists(“json_encode”))’ return TRUE;

    However as soon as I run this from a PHP script in apache; I get False;

    Anyone care to help?

    Thanks

    • Hey, I’ve got exactly the same problem.
      JSON module appears in the command line PHP module (CentOS 4.4, PHP 5.1.6) but it doesn’t shows up in Apache (However phpinfo() shows the json.ini file loaded BUT not the .so)

  5. Fatal error: Call to undefined function json_last_error()…

    Any ideas?

  6. i tried to install it using the pear command.but showing something like this bash: pear: command not found.plz help

  7. @Andy
    @hm2k
    I faced these problems as well. There are a few steps required outlined in the writeup URL below. Basically, you need to add json.so to the list of extensions that PHP uses, and you need to restart your webserver.

    http://slaptijack.com/system-administration/lets-install-json-for-php-5/

  8. Your method didn’t work for me, but I did get it to work like this:

    make sure you have a c complier installed (if you’re not sure do: yum install gcc)
    then do:

    pecl install json

    You’ll see a lot of info passing on your screen, just make sure the last 2 lines say the install is ok.

    cheate a new file:

    /etc/php.d/json.ini

    that contains the following line:

    extension=json.so

    now restart apache:

    service httpd restart

    That fixed the problem for me….

  9. This is how I did it:

    I have PHP 5.1.6 too.

    Run:

    yum install php-devel
    yum install php-pear
    yum install gcc
    pecl install json

    create a new file called json.ini in this directory: /etc/php.d/json.ini

    add this in json.ini: extension=json.so

    restart apache with this command:
    service httpd restart

    AND THAT”S ALL! Good luck! ;)

  10. Hi all,
    I did the complete process to install json on RHEL/php5.1.6 as exposed earlier.
    However as Andy earlier, php answer that json function exist on command line (return true) but not from a php script called by apache.
    I told php to load json.so module too but it’s still not working.

    Any help please here to nuderstand why the command line way works and the php’s script doesn’t.

    Thanks for help :)

  11. I have just found the answer on the net!!! Andy if u are here…

    do:
    cd /usr/lib/php/module/
    strip json.so

    And now all is good with a php script

    Have fun with json :)

  12. @Ecox method works. If you missed it
    Run:

    yum install php-devel
    yum install php-pear
    yum install gcc
    pecl install json

    create a new file called json.ini in this directory: /etc/php.d/json.ini

    add this in json.ini: extension=json.so

    restart apache with this command:
    service httpd restart

Trackbacks

User contributed tags for this post:

php 5.1.6 json (728) - centos php json (377) - php 5.1 json (348) - Json php 5.1.6 (337) - json php 5.1 (264) - php json rpm (256) - php json centos (249) - php-json rpm (217) - yum php json (184) - yum json (174) - yum install json (169) - yum install php json (148) - centos json (142) - json centos (130) - php json 5.1.6 (118) - php-json centos (103) - centos php-json (101) - yum install php-json (97) - json php centos (84) - php json 5.1 (82) - Enable Json in PHP (81) - php-json-5.1.6 (79) - PHP json yum (75) - centos 5 php json (72) - JSON rpm (72) - redhat php json (68) - install json centos (65) - json for php 5.1.6 (65) - json redhat (58) - yum php-json (56) - rhel php json (53) - centos json php (47) - php 5.1.6 (47) - rhel json (46) - install json (46) - install json php 5.1.6 (46) - centos install json (46) - json centos 5 (45) - php json rhel (45) - redhat json (44) - json yum (43) - php JSON Redhat (42) - json php rpm (41) - centos install php json (38) - php json centos 5 (37) - install json php (37) - centos 5 json (37) - pear install pecl/json (36) - pecl install json (35) - php-json 5.1.6 (35) - pear install json (34) - yum json php (34) - php-json centos 5 (34) - json in php 5.1.6 (32) - centos php json rpm (31) - php json rhel5 (31) - json_encode php 5.1.6 (30) - php-json rpm centos (30) - php enable json (29) - pecl json centos (29) - php json rpm centos (28) - centos pecl json (28) - php json install (28) - json rhel (26) - PHP Version 5.1.6 json (26) - rhel5 json (26) - json php yum (26) - enable json php (24) - PHP 5.1.6 JSON rpm (24) - yum install json php (24) - install php json (23) - 5.1.6 json (23) - php-json centos rpm (23) - install json php 5.1 (23) - centos 5 php-json (23) - centos php 5.1.6 (22) - json php redhat (22) - rhel 5 php json (22) - rhel5 php json (21) - install php json centos (21) - rpm php-json (21) - centos php json yum (21) - php JSON yum install (21) - php JSON (20) - php-json yum (20) - json on php 5.1.6 (20) - json in php 5.1 (19) - php 5.1.6 install json (18) - php-json redhat (18) - red hat php json (18) - php json centos rpm (18) - json php rhel (18) - php-json rhel (18) - install json php centos (18) - php-json rhel5 (17) - php-json-5.1.6 rpm (17) - php install json (17) - centos php 5.1 json (17) - php centos json (17) - json plesk php 5.1.6 (17) - json rhel 5 (16) - install JSON centos 5 (16) - yum pecl (16) - redhat install json (16) - json red hat (16) - php 5.1.2 json (15) - json 5.1.6 (15) - yum install php-pecl-json (15) - json rpm centos (15) - json php rhel5 (14) - centos php-json rpm (14) - install json redhat (12) - rhel php-json (12) - how to install JSON (12) - json install centos (12) - rhel 5 json (12) - centos json install (12) - centos5 php json (12) - install json on centos 5 (12) - php-pecl-json centos (12) - install (11) - centos 5 json php (11) - json install (11) - php-json.rpm (11) - php json red hat (11) - centos php json install (11) - json redhat 5 (11) - redhat enterprise 5 installing php json (11) - json_encode php 5.1 (11) - php 5.1 json install (10) - php 5.1 install json (10) - JSON php CentOS 5 (10) - pecl json install (10) - RHEL php (10) - pear json (10) - php-5.1.6 (10) - php json rpm 5.1.6 (10) - centos json rpm (10) - centos yum json (10) - install json RHEL (10) - RHEL5 pecl (10) - php-pecl-json (10) - php 5.1 json centos (10) - centos 6 (9) - json support PHP 5.1 (9) - redhat php-json (9) - rhel pecl (9) - php 5.1.4 json (9) - json php 5.1.2 (9) -