How to install PHP-Json module on a Linux server?

 To install/enable Json support for PHP on a Linux  server, follow the below steps:

1. Install php-pear and gcc

# yum install php-pear gcc

2. Install json module

# pecl install json

3. Now, the file is created under the php lib directory i.e. /usr/lib64/php/modules/ and needs to be called in the json.ini so PHP configuration could read it.

# cd /etc/php.d
# echo "" >> json.ini

4. Once done, restart the httpd service

# /etc/init.d/httpd restart

This is it. However, the other way is to install the php-json module manually. Follow the below steps:

1. Download the json package

# wget
# pecl download json

2. Untar and goto the newly created directory

# tar -zxf json-1.2.0.tgz
# cd json-1.2.0

3. Create the configuration files and configure json

# phpize
# ./configure

4. Create the installation file and install it

# make
# make install

Once done, will be created in /usr/lib64/php/modules/ directory and needs to be called by the php configuration directory

# cd /etc/php.d
# echo “” >> json.ini

Restart the httpd service and check the php-json module by executing

# php -m | grep json

One thought on “How to install PHP-Json module on a Linux server?”

  1. If you have sh: phpize : command not found ERROR: `phpize’ failed
    after # pecl install json
    You need to install php-devel : yum install php-devel

Leave a Reply

Your email address will not be published. Required fields are marked *