Install JSON on Plesk server

 

Howto install JSON on a CentOS Plesk server running PHP 5.1

JSON comes by default installed with PHP5.2 and newer. So if you cannot upgrade to 5.2 then  read below the easy steps to install it:

Login to your server with SSH and become root.
Then here are the commands to install it with Pecl:

pecl install json

That should do the job…
Now check if it is really there:

On a 64bit machine:
ls -al /usr/lib64/php/modules/json.so

On a 32bit machine:
ls -al /usr/lib/php/modles/json.so

Then make sure it is activated in php.ini:
echo extension=json.so >> /etc/php.d/json.ini

Restart Apache:
service httpd restart

Now we can check it by calling phpinfo():
create a file, e.g. info.php, containing following lines:

<?php
phpinfo();
?>

Now call this file with your browser, like e.g.: http://www.yourdomain.nl/info.php

The page should now display some information on JSON, like:

json support: enabled
json version: 1.2.1