Wednesday, March 23, 2011

Install JSON PHP Extension on CentOs


I needed to install JSON on a Centos 5.4 server with PHP 5.1.6 installed there. So, I tried those steps, and it worked fine. Very helpful article.

NOTE: As of PHP 5.2, json extension is now standard. If you’re running PHP 5.2 or later, or like to upgrade instead, you can skip this!
   1. Ensure you have the necessary dependecies (php, php-pear, php-devel, gcc, make):
          * $ sudo yum install gcc make
    * $ sudo yum install php php-pear php-devel
   2. Use PECL (PHP Extension Community Library) to download the json package:
          * $ sudo pecl download json
   3. Use PEAR (PHP Extension and Application Repository) to extract and install the extension:
          * $ sudo pear install json-1.2.1.tgz
   4. Create a file in /etc/php.d called “json.ini”, and add the following lines:
          * ; php-json extension
    * extension=json.so
   5. Restart apache (gracefully if you’re running a live site:
          * $ sudo service httpd restart (apachectl graceful)
   6. Check for availability by creating an info.php file in the web root with the following line:
          * <?php phpinfo(); ?>
   7. Load info.php in your browser and check for JSON. You now should be all set, but if it doesn’t appear, verify all of the above steps very carefully.
References: 
http://www.itecsoftware.com/web-development/install-json-php-extension-on-centos-redhat 

11 comments:

Anonymous said...

thank you!

Yasmen R. El-Shaa'rawy said...

You welcome :)

Beta said...

I want to install JSON PHP extension on my CentOS, thanks already to guide how to install.

Yasmen R. El-Shaa'rawy said...

Thanks to the original author :)

You welcome anytime though!

Anonymous said...

Thank you!!!

Yasmen R. El-Shaa'rawy said...

Anytime! :)

Bob said...

Not everything works perfectly in everyone's world. Any ideas how to resolve this:

# pear install json-1.2.1.tgz
11 source files, building
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module

ERROR: `phpize' failed

This is on a Centos 6 machine. All required packages are installed and up to date.

Yasmen R. El-Shaa'rawy said...

Well, not very sure that I know the solution but here's some tips:

- Google using "Centos6" so you may have specific solution for Centos6

- Post your problem with more details at PHP or developers forums such as StackOverflow or so.

- You may try those links:
# http://www.arckid.com/blog/amfphp/how-to-add-install-json-support-to-php-on-centos-in-10-steps/

# http://stackoverflow.com/questions/7979864/php-5-3-8-json-centos-6

Hope I coud help!

STAR said...

In CentOS6...
download json-1.2.1.tgz FROM PECL
>tar zxvf json-1.2.1.tgz
>cd json-1.2.1
>vi JSON_parser.c

Find ZVAL_DELREF replace to Z_DELREF_P
(You can Find in 3 place)
And Save file

Then
>phpize
>./configure
>make
>make install
You can get your json.so
don't forget add to php.ini
Write by STAR

Deano said...

You have fixed my issue, thank you so much star!

Anonymous said...

you are God

John