Adding JSON support to CentOS 5

For our webserver, we still run php 5.1 as thats whats part of the CentOS 5 repos and since a few of our sites run on Drupal 5 and you get nothing but errors when trying to run php 5.3. Recently our webdev was trying something and found we did not have json support. He wrote his own workaround as he is just that good, but as a good sysadmin, I set out to provide json support.

First as always make sure your packages are up to date. If php-pear isnt installed, then install it. We need the pcel command to install json support.

pecl install json

Then since php is already setup to read /etc/php.d for extra configuation info, create /etc/php.d/json.ini and add

extension=json.so

I created a simple php page that prints out php info, so I try the following to check if it worked

php info.php | grep json

/etc/php.d/json.ini,
json
json support => enabled
json version => 1.2.1

If you see the above, all is good. Then restart the webserver and check your sites.

Thanks go to Ashvin Savani – Arckid.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s