Tag Archives: JSON

Install And Use CouchDB With JSON And Map-Reduce

CouchDB is another offspring from the open-source, NoSQL, non-relational databases and is maintained under the Apache Foundation. It differs itself form the likes of MongoDB or Cassandra in that CouchDB is storing data in so called “documents” that are in JSON format, which can be hashes, lists, nested arrays and of course scalar values. This added complexity results in more powerful features, mainly to have a db that is not just a single key/value pair, but it comes at a price of speed reduction.

CouchDB can be a little bit of a pain to install, because it needs a few pre-requisites and they in turn have a few of their own quirks. This outline should help you get CouchDB with all it’s necessities installed. We’ve used MacOS, but you can substitute your OS where applicable.

The CouchDB source code and installer packages are downloadable here. As of this writing, version 0.11.2 is the latest stable version, with 1.0.1 just around the corner. You will also need Spider Monkey, Mozilla’s C implementation of JavaScript.

Installing SpiderMonkey

Once downloaded, extract the tarball and move into the sources folder:

tar -xzvf js-1.8.0-rc1.tar.gz

cd js/src

Read more »

Install JSON PHP Extension on CentOs / RedHat

I had numerous requests for info and questions relating to JSON extension in CentOS. To enable these functions in RedHat and CentOs 5, the process is really simple and fast.

NOTE: As of PHP 5.2, json extension is now standard. If you’re running PHP 5.2 or later, or like to upgrade instead, you can skip this!

  1. Ensure you have the necessary dependecies (php, php-pear, php-devel, gcc, make):
    • $ sudo yum install gcc make
    • $ sudo yum install php php-pear php-devel
  2. Use PECL (PHP Extension Community Library) to download the json package:
    • $ sudo pecl download json
  3. Use PEAR (PHP Extension and Application Repository) to extract and install the extension:
    • $ sudo pear install json-1.2.1.tgz
  4. Create a file in /etc/php.d called “json.ini”, and add the following lines:
    • ; php-json extension
    • extension=json.so
  5. Restart apache (gracefully if you’re running a live site:
    • $ sudo service httpd restart (apachectl graceful)
  6. Check for availability by creating an info.php file in the web root with the following line:
    • <?php phpinfo(); ?>
  7. Load info.php in your browser and check for JSON. You now should be all set, but if it doesn’t appear, verify all of the above steps very carefully.