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!References:
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
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.