Installing php json pecl extension on centos
The json extension for php enables some useful functions: json_encode and json_decode. Unfortunately the centos repository version of php does not come precompiled with the json extension and they do not have a php-json package that you can install from the repository. Luckily it isn't too hard to build that extension through the pecl extension repository.
First you must make sure you have pear and php devel packages installed.
yum install php php-pear php-devel
You will then need to make sure you have the C compiler installed.
yum install gcc make
Some people have reported issues when installing the json extension directly from pecl, so you can download the extenion through the pecl command and install it using pear.
pecl download json
pear install json-1.2.1.tgz
After that, the json extension is installed. The installation process does not automatically add the extension in the configuration file to be loaded, so you will need to do that. You can create a file /etc/php.d/json.ini that contains the following
extension=json.so
Then all you will need to do is restart apache.
service httpd reload
After this you should have the json_encode and json_decode functions available to you in your php scripts.
If need be, you can double check that the json extension is loaded by checking the result of phpinfo(). You should see a section with a heading "json", stating that json support is enabled.