JSON - A PHP Extension For Linux

Install JSON in Linux JSON stands for (JavaScript Object Notation) is a lightweight text-data interchange format for both human and machine readable. It is derived from the JavaScript programming language for representing simple data structures and associative arrays, called objects. It is based on JavaScript Programming Language and completely language independent and much smaller than XML, and much faster and easier to parse. It is used for data interchange between programs, an area in which the ubiquitous XML is not too well-suited. JSON is lightweight and works extremely cleanly with languages including JavaScript, Python, PHP, Java, C++, and many others.

In this post I will show you how to install JSON extension for your PHP support. I selected CentOS 5.6 for JSON installation for my PHP 5.2, but don't worry this installation also works on many UNIX-like distribution. Let's begins installation procedure by following steps.

How To Install JSON In Linux

1. Let's first install the required dependencies for JSON with YUM tool.
# yum install gcc make php php-pear php-devel
2. Use PECL (PHP Extension Community Library) to download the JSON tool.
# pecl download json
3. Extract the downloaded JSON package with TAR commands.
# tar -xvf json-1.2.1.tgz
4. Next install JSON package with using below commands.
# cd json-1.2.1
# phpize
# ./configure
# make
# make install
5. Now create a file json.ini under /etc/php.d.
# touch /etc/php.d/json.ini
6. Now add following lines to json.ini file.
# vi /etc/php.d/json.ini
; Enable json extension module
extension=json.so
7. Next restart Apache service.
# service httpd restart
8. Test JSON extension working or not.
# php -m | grep json
9. Done! If you are facing any problem while installing JSON, please leave a comment below I will surely help you out.

0 comments: