Attach And Mount EBS Volume To EC2 Linux Instance

AWS allows to create / attach / mount new EBS volumes to instances for extra storage. Use lsblk command to view available disk devices and other mount points.

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 8.0G 1.6G 6.5G 20% /

– Go to EC2 Console –> Volumes to create new volume of required size and type.

– Select the last created volume and select the “attach volume” to attach to the ec2 instance.

– Now, SSH login to ec2 instance and find list of available disks or mounts.

# lsblk
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdf 202:80 0 16G 0 disk

Check the volume has data or empty
# file -s /dev/xvdf

Format the volume to ext4 file system type
# mkfs -t ext4 /dev/xvdf

Mount the volume to “/mnt/dir/” directory
# mkdir /mnt/dir/
# mount /dev/xvdf /mnt/dir/ -t ext4

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 8.0G 1.6G 6.5G 20% /
/dev/xvdf 16G 45M 15G 1% /mnt/dir

# lsblk
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdf 202:80 0 16G 0 disk /mnt/dir

EBS Automount On Reboot using fstab
# cp /etc/fstab /etc/fstab.bak

Write FSTAB file
# vi /etc/fstab
/dev/xvdf /mnt/dir ext4 defaults,nofail

Check errors
# mount -a

How to unmount volume??
# umount /dev/xvdf


Free Cloud Server Hosting

Benefits of Free Cloud Hosting

* Self-Managed with Console
* Free storage
* Easy application deployment
* Production ready apps
* Cloud hosts (IaaS)
* Automatic backup & recovery
* Server resizing
* Migration facility
* Portability
* Cloud portability
* Free bandwidth
* Enhanced performance
* High availability of resources
* Data storage redundancy
* Growth flexibility
* Economical

AWS Free Usage Tier

Deploy a Sample Web Application in the Free Usage Tier
Deploy a Sample Web Application in the Free Usage Tier

Google App Engine – Easy to build, Easy to scale, Easy to maintain
Try Free … Google Cloud Storage, Google BigQuery and Google Cloud SQL

Google App Engine — Google Developers
Google App Engine — Google Developers

PHPCloud – Zend Developer Cloud, as its name suggests, a cloud-based environment designed to help you code more quickly and more efficiently. It includes a robust PHP stack, advanced debugging capabilities, collaboration tools and much more. Zend Developer Cloud is only a few clicks away and does not require any installation. To make it even better, it’s absolutely free!

PHP Cloud
PHP Cloud

HP Cloud – Open source-based public cloud computing HP tailored for developers and enterprise. Ready-to-use Storage, PaaS, IaaS, solutions from a rich partner community.

Cloud Computing - HP Cloud Services - Storage
Cloud Computing – HP Cloud Services – Storage

AppFog – The Best Public Cloud PaaS, Now Available on Private Clouds Simple, elegant, and modern way to develop and deploy apps. Unlimited apps within 2GB RAM, Up to 8 service instances 100MB per MySQL or PostgreSQL instance. Rock-solid Cloud Platform for PHP by AppFog.

AppFog- PaaS for Public and Private Clouds
AppFog- PaaS for Public and Private Clouds

Xeround – A ridiculously simple, seriously powerful CLOUD DATABASE Xeround is an elastic, always-on database-as-a-service for your MySQL applications.

Cloud Database
Cloud Database

ClearDB is a reliable, fault tolerant database-as-a-service for your MySQL powered applications.

ClearDB - The Ultra Reliable, Globally Distributed Cloud Database For Your MySQL Applications
ClearDB – The Ultra Reliable, Globally Distributed Cloud Database For Your MySQL Applications

Gozure is cloud hosting built for website and blog owners. Run WordPress, Joomla, Drupal, and many other web applications on our powerful platform and get started for free. Gozure uses a simple control panel so no technical experience is necessary.

Gozure - Free Cloud Hosting
Gozure – Free Cloud Hosting

BitNami provides free, ready to run environments for your favorite open source web applications and frameworks, including Drupal, Joomla!, WordPress, PHP, Rails, Django and many more. And with BitNami Cloud Hosting, enjoy automatic backups, monitoring, and more.

BitNami- Open Source. Simplified
BitNami- Open Source. Simplified

PagodaBox is a relatively new Cloud PaaS provider, accessed at PagodaBox markets itself is a PHP specialist. This is proven by the fact that PagodaBox features popular PHP projects like PyroCMS, WordPress, Kohana and CodeIgniter for easy 1-click installations.

Premier Cloud Hosting
Premier Cloud Hosting

OpenShift is Red Hat’s free, auto-scaling Platform as a Service (PaaS) for applications. As an application platform in the cloud, OpenShift manages the stack so you can focus on your code.

OpenShift by Red Hat
OpenShift by Red Hat

Cloud Foundry – Deploy and scale applications in seconds, without locking yourself into a single cloud.

Cloud Foundry
Cloud Foundry

Apprenda is an Open Platform as a Service (PaaS) stack that enables any organization to transform their existing infrastructure into a self-service cloud application platform.

Open Platform as a Service (PaaS) for .NET - Apprenda
Open Platform as a Service (PaaS) for .NET – Apprenda

The CloudBees Platform as a Service (PaaS) architecture provides a powerful foundation for cloud development and deployment services.

CloudBees- The Java PaaS Company
CloudBees- The Java PaaS Company

Orchestra is a Platform as a Service for deploying (PHP Hosting), scaling and managing PHP applications. Built on Amazon Web Services, it integrates with your workflow, autoscales up and down and gives you extra capabilities with powerful add-ons. Engine Yard provides a portfolio of options that let you begin deploying for your applications for free and then allows you to upgrade to elastic, dedicated resources when you’re ready to go into production. Think Orchestra PHP hosting for PHP development.

Ruby On Rails and PHP Cloud Hosting PaaS - Managed Rails Development - Engine Yard Platform as a Service
Ruby On Rails and PHP Cloud Hosting PaaS – Managed Rails Development – Engine Yard Platform as a Service

Jelastic Java Host – Rock-solid Java in the Cloud Auto-scales. Easy to deploy. Runs ANY Java app.

Jelastic — Top Java Host, Rock-Solid Java in the Cloud, Java Server Hosting, Java Cloud Computing
Jelastic — Top Java Host, Rock-Solid Java in the Cloud, Java Server Hosting, Java Cloud Computing

dotCloud – Build your ideal application stack by combining powerful cloud services. Experiment for free, then go live and only pay for what you need.

dotCloud - One home for all your apps
dotCloud – One home for all your apps

Cloudflare – Give us five minutes and we’ll supercharge your website.

CloudFlare - The web performance & security
CloudFlare – The web performance & security

And Many More ……..

If you are really interested in Cloud Computing, you can find more “Free PaaS” or “Free Cloud” to take advantage of free cloud hosting 😉

Amazon S3 Error Handling

Amazon S3 PHP Class A standalone Amazon S3 (REST) client for PHP 5.2.x using CURL that does not require PEAR.

AWS Management Console Home
AWS Management Console Home

AMAZON S3 (Scalable Storage in the Cloud) PHP CLASS

AWS access info
AWS access info

// AWS access info
if (!defined(‘awsAccessKey’)) define(‘awsAccessKey’, ‘CHANGE-KEY’);
if (!defined(‘awsSecretKey’)) define(‘awsSecretKey’, ‘CHANGE-KEY’);

OO method (e,g; $s3->getObject(…)):
$s3 = new S3(awsAccessKey, awsSecretKey);

Statically (e,g; S3::getObject(…)):
S3::setAuth(awsAccessKey, awsSecretKey);

Warning: S3::getBucket(): [PermanentRedirect] The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

We need to End Point for our S3 Buckets by default it’s

$s3 = new S3(awsAccessKey, awsSecretKey);

S3 Management Console
S3 Management Console

Else we need to specify here…

S3 Management Console
S3 Management Console

$s3 = new S3(awsAccessKey, awsSecretKey, true, ‘‘);

Warning: S3::getBucket(): [60] SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

We need SSL enabled with CURL 😉

OpenSSL phpinfo()
OpenSSL phpinfo()
CURL With OpenSSL phpinfo()
CURL With OpenSSL phpinfo()

For class documentation see:

AWS CloudFront with PHP

Amazon CloudFront is a web service for content delivery (CDN). It integrates with other Amazon Web Services EC2 / S3 to give developers and businesses an easy way to distribute content to end users with low latency and high data transfer speeds.

Digital Inspiration – Thanks to… it always provides help for all latest technologies 🙂

You can follow basic steps here to setup CloudFront with Amazon S3 with your domain…
How to Setup Amazon S3 with CloudFront as a Content Delivery Network

You can download Cloudfront keys from AWS account


$file="svnlabs.flv"; // file on Amazon S3

function rsa_sha1_sign($policy, $private_key_filename) {
    $signature = "";

    // load the private key
    $fp = fopen($private_key_filename, "r");
    $priv_key = fread($fp, 8192);
    $pkeyid = openssl_get_privatekey($priv_key);

    // compute signature
    openssl_sign($policy, $signature, $pkeyid);

    // free the key from memory

    return $signature;

function url_safe_base64_encode($value) {
    $encoded = base64_encode($value);
    // replace unsafe characters +, = and / with the safe characters -, _ and ~
    return str_replace(
        array('+', '=', '/'),
        array('-', '_', '~'),

function encode_query_params($stream_name) {

    return str_replace(
        array('?', '=', '&'),
        array('%3F', '%3D', '%26'),

/// Download from here...

$private_key_filename = 'pk-XXXXXXXXXXXXXXXXXXXX.pem';
$cloudfront= '';

$file_location = "$cloudfront$file";

$expires = time() + 3;  // 3 min from now
$remote_ip = $_SERVER['REMOTE_ADDR'];

$policy = 
            '"Resource":"'. $file_location . '",'.
                '"IpAddress":{"AWS:SourceIp":"' . $remote_ip . '/32"},'.
                '"DateLessThan":{"AWS:EpochTime":' . $expires . '}'.
    ']' .

$encoded_policy = url_safe_base64_encode($policy);
$signature = rsa_sha1_sign($policy, $private_key_filename);
$encoded_signature = url_safe_base64_encode($signature);

<title>CloudFront Implementation in PHP</title> 
<a href='<?php echo "$file_location$streamer"; ?>'><?php echo "$file_location$streamer"; ?></a> 

A Master inspires you by his being & learning happens. 😉

I have Cloud Power

Amazon Web Services

AWS is an IaaS platform and provides maximum freedom for developers in choice of the OS, middleware and development environment.
Google App Engine + Google Apps

Google App Engine is used as SaaS, it provides free limited resources (disk space and bandwidth), GAE supports programming languages – PHP, Python and Java.


Nothing to explain it is the place where (almost all) clients live with sharing content.


Rackspace is like Amazon cloud in IaaS and cost is quite reasonable.

Scalr will provision new servers on-the-fly to handle spikes in demand, and decommission them when no longer needed to lower cost.. then your website and web application can grow to millions of users with little work.


Cloud Computing Management Platform…Join thousands of companies managing their applications in the cloud with RightScale.

IBM Cloud

IBM Cloud is used in large companies and resource-intensive processes for managing software development, testing, storage and processing of huge data.

VMWare vCloud

VMWare Cloud is leader in virtualization. is provider of SaaS applications. Salesforce allows to create system and independent cloud applications.

Ghost Cloud

It provides private hard disk across the Internet for your files from any computer or cell phone and world-class backup and security.

Glide Cloud is provider of SaaS applications. Salesforce allows to create system and independent cloud applications.


Any Browser + Cloud Computing + Pay-As-You-Go = ZeroPC.


eyeOS have Ubiquity, Flexibility, Integration, Simplicity, Collaboration, Privacy, Security, Low Costs.


AirSet – Share with Facebook Friends, Coordinate Schedules, Store & Back Up Files, Sync to Mobile Devices, Work from Anywhere.

My Gladinet Drive

SaaS built using a PaaS (Google App Engine) and using IaaS (Amazon EC2)

SaaS = PaaS + IaaS

Historical Method - VaR Cloud App.png

Tools for Development, Testing and Implementation:
* Amazon Web Services (AWS)
* Google App Engine (GAE)
* Google Chart Libraries
* Eclipse IDE

VaR Cloud Presentation SVNLabs

Google AppEngine:
Amazon EC2:
Google Chart:

“A lamp does not speak. It introduces itself through it’s light. Achievers never expose themselves. But their achievements expose them..!!!”

JSP S3Upload

JavaScript is good alternative to bypass AWS bucket policies 😉

<%@ include file="config.jsp" %>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.Date"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns=""><head>
<title>S3 Upload - JSP Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script src="sha1.js"></script>
<script src="webtoolkit.base64.js"></script>
<script src="script.js"></script>


function uploadS3()
var awsid = '<%=awsAccessKey %>';
var awskey = '<%=awsSecretKey %>';

var fileField = document.getElementById("file").value;

var policyText = '{"expiration": "2015-01-01T12:00:00.000Z","conditions": [{"bucket": "<%=bucket %>" },{"acl": "<%=acl %>" },["eq", "$key", "'+fileField+'"],["starts-with", "$Content-Type", "text/"],]}'; 

var policyBase64 = Base64.encode(policyText);

var signature = b64_hmac_sha1(awskey, policyBase64);

document.getElementById("policy").value = policyBase64;
document.getElementById("signature").value = signature;
document.getElementById("key").value = fileField;


document.getElementById("result").innerHTML = '<a href="<%=bucket %>/'+fileField+'"><%=bucket %>/'+fileField+'</a>'; 




<strong>Uploading to Amazon S3</strong>

<div class="main">


<form id="postform" action="<%=bucket %>" method="post" onsubmit="return uploadS3();" enctype="multipart/form-data">
<input type="hidden" name="key" id="key" value="" />
<input type="hidden" name="acl" id="acl" value="<%=acl %>" />
<input type="hidden" name="content-type" id="content-type" value="text/plain" />
<input type="hidden" name="AWSAccessKeyId" id="AWSAccessKeyId" value="<%=awsAccessKey %>" />
<input type="hidden" name="policy" id="policy" value="" />
<input type="hidden" name="signature" id="signature" value="" />
<input name="file" id="file" type="file" />
<input name="submit" value="Upload" type="submit" />

<div id="result"></div>


PHP based S3 Upload Tool:

You are great if you can find your faults, Greater if you can correct them, But greatest if you accept others with their faults.

How to Setup Elastic Load Balancing on AWS

Amazon S3 & Facebook Fanpage app

I want to link Amazon S3 https object like “” to facebook iframed fan page…
But it returned error….

405 Method Not Allowed
Code: MethodNotAllowed
Message: The specified method is not allowed against this resource.
ResourceType: OBJECT
Method: POST


PreconditionFailedAt least one of the pre-conditions you specified did not holdBucket POST must be of the enclosure-type multipart/form-data….. 🙁


<Message>At least one of the pre-conditions you specified did not hold</Message>
<Condition>Bucket POST must be of the enclosure-type multipart/form-data</Condition>

After few searches I got link…. but not helpful 🙁

Finally, I got good article on AWS Forum..

I came to know that facebook loads the requested HTTPS S3 URL “” by sending a form POST and injected some content into the iframe, but S3 have POST for file uploading only… so it returned “MethodNotAllowed”

Bucket Policies won’t work in this condition… 🙁

Now, I have few options to use S3 HTTPS Object “” in facebook iframed fan page…

1. Run a HTTPS Apache server that can load S3 HTTPS Object with POST method and supply to fan page 🙂
2. Load S3 HTTPS Object using another iframe on any server… see code below

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Facebook Fan Page - Amazon S3</title>

<iframe frameborder="0" style="width: 520px; height: 800px;" src="" scrolling="no"></iframe>

You can check videos released on blog 9th May 2011 for more detailed installation…

I have partnered with Shelle Kind of facebook social marketing and we have released the Amazon S3 / EC2 Solution for Facebook fanpage apps.

Partner: Shelle-K | Custom graphic and web developer

When MIND is weak situation is a PROBLEM, when MIND is balanced situation is CHALLENGE, when MIND is strong situation is an OPPORTUNITY 😉

Amazon E-Commerce Service or ECS

Amazon’s ECS is very good service for accessing Amazon’s product database. We can register to this web service quickly, It provides a free access key to access Amazon Store.

Amazon have rich set of web services 🙂 Web Services are used to access DATA over cross platform environments.

Using ECS-driven websites and applications, we can earn commissions by advertising items for sale by Amazon.

Amazon E-Commerce Service can be used to get the information from amazon such as product name, images, availability, ratings, description, specifications, similar products, and more.

We can use PHP to consume web service using PEAR, REST, SOAP and XML etc.


There is one thing which gives radiance to everything. It is the idea of something around the corner.