How to Install CouchBase 2.0.1 Enterprise Server on Centos with php-ext-couchbase.

Couchbase is a simple, fast and elastic document-oriented database.

Installing Couchbase 

# yum -y groupinstall "Development Tools"
# yum -y install openssl098e
# wget http://packages.couchbase.com/releases/2.0.1/couchbase-server-enterprise_x86_64_2.0.1.rpm
# rpm --install couchbase-server-enterprise_x86_64_2.0.1.rpm
Browse the URL : http://localhost:8091/ and finish the installation steps.(Will post these steps with all imagest very soon :))

Installing PHP

# yum -y install php
# yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout php-snmp php-soap php-tidy

Installing php-ext-couchbase

# wget -O /etc/yum.repos.d/couchbase.repo http://packages.couchbase.com/rpm/couchbase-centos62-x86_64.repo
# yum install -y libcouchbase2 libcouchbase-devel libcouchbase2-libevent
# wget http://packages.couchbase.com/clients/php/php-ext-couchbase-1.1.2-centos62-x86_64.tar.gz
# tar -xvf php-ext-couchbase-1.1.2-centos62-x86_64.tar.gz
# cd php-ext-couchbase
# cp couchbase.so /usr/lib64/php/modules
# echo "extension=couchbase.so" >> /etc/php.d/josn.ini
# /etc/init.d/httpd restart

To verify the php extension

# php -m | grep couchbase
Output: couchbase

Some basic usage:

Let’s create 10 JSON documents and store them in Couchbase:

<?php

$connection = new Couchbase("127.0.0.1:8091");

for($i=0;$i<10;$i++) {
$doc = array(
'title' => "This is Post $i"
);
$connection->set("post_$i", json_encode($doc));
}

?>

You can view your stored documents instantly through the GUI (http://localhost:8091/index.html#sec=documents&bucketName=default). Now we can retrieve all documents again by their keys:

<?php

$connection = new Couchbase("127.0.0.1:8091");

echo "<ul>";
for($i=0;$i<10;$i++) {
$post = json_decode($connection->get("post_$i"));
echo "<li>" . $post->title .  "</li>";
}
echo "</ul>";

?>
Follow

Get every new post delivered to your Inbox.

Join 198 other followers

%d bloggers like this: