Linux : How to add JSON support to CentOS 5 PHP 5.1.6

By | July 2, 2012

JSON support come natively with PHP 5.2 and later. If you are running CentOS Linux 5, this is PHP version 5.1.6 that is included by default. Fortunately, since version 5.6, CentOS packaged version 5.3.3 of PHP that can be installed through YUM (not included in the ISO set).

If you still run applications that can’t run on recent version of PHP, there is a workaround to get JSON support to PHP 5.1.

1. Make sure your system/PHP is up2date first :

If you only want PHP update, do :

NOTE : The next step require GCC compiler, if you do not have it installed on your server, just do :

2. Install JSON module through Pecl :

3. Create the extension file to make it effective :

With the following content :

4. Now, you need to restart Apache to load the extension :

NOTE : You can now remove GCC if you do not require it for more security :