Tuesday, May 20, 2014

working with ibm bluemix for deploying PHP application on cloud - cloud foundry

As i mentioned about my cloud experience in Heroku and attended a workshop on IBM cloud ,i had an opportunity to deploy my php application on +IBM.I got success in deploying my PHP application instant manner from my windows platform.i am so thankful to +vikas sir for introducing the bluemix through workshop session,as i mentioned in my last post.bluemix is under beta version and open to all till june.





Scope:

we could deploy php application on cloud,Create services and run database.Since i am currently using Windows 8 i would show commands and screenshot from Command Prompt.

Requirements:

> IBM ID (mandatory) with developer registration(may be useful for forums)
> Sign Up for Beta Bluemix with IBM ID (Click Here)
> Constant Internet Connection ;)
> A small php project

Installation:

Go to Official Download page for cloud foundry tool for connecting with cloud.

1) It's better to download the Stable version.
2) Select the appropriate OS and download the zip and extract.
3) Run the installer with Admin Permissions only then You won't get errors.

After Installation:

Just it will be installed In Program files in your Windows Local Disk.
1) Now open your Command prompt with Administrative Permission.
2) And type "cf" and space "-v" (option)

    C:/>cf -v   // it must output with version number of the Cloud foundry tool Application


thus CF tool is working in your command prompt.lets start initial steps to deploy our application.


manifest.yml:

This is the important step in deploying app.This is the basic app settings ,it speaks with the cloud that you need the particular setup to run your corresponding app.Simply saying it is going to initialize cloud environment for deploying.So,let us concentrate on creating manifest.yml file.note this file must be with your project files while uploading.


---
applications:
- name: NAME-OF-YOUR-FOLDER-APP
  memory: 256M
  instances: 1 
  host: WEBSITE_ADDRESS_FOR_YOUR_APP(host)
  buildpack: https://github.com/dmikusa-pivotal/cf-php-build-pack


Actual manifest.yml of my app (note that above three hyphens must be mandatory and hyphen before name is also must)

don't change Buildpack(pulling it from git php built pack),memory(actual RAM memory limit) and instance(balance load using instance).if you change it you may be charged accordingly as per price plans.



---
applications:
- name: myapp
  memory: 256M
  instances: 1 
  host: shivamyapp
  buildpack: https://github.com/dmikusa-pivotal/cf-php-build-pack


see through that your host must be unique(app web address).may be in future you can make it your custom domain.

Deployment of app:

1) Just point your API .type this in your command prompt(ADMIN)
C:/> cf api https://api.ng.bluemix.net

2) and change directory where your project file to be uploaded.
C:/> cf login

3) Enter your E-Mail ID and Password of IBM ID
just click on it and view cf login
4) after changing directory where your project exisit.(move inside where manifest.yml present) and type the command
$ cf push myapp

since i had named my folder project name i had written as myapp(replace with your app project folder name and must be same as application name in manifest.yml)

5) by executing above command just you must get like this below image.That your upload works and moving to cloud foundry.
your project file uploading via CMD
6) After that it executes many configuration and restarts the application.this mean that your Host name is correct and working.
go to Provided_Host_name.ng.bluemix.net (hostname provided in manifest.yml)
eg: myapp.ng.bleumix.net

7) While updating your application just use step number 4,5.

note: Work with caution because cloud may costs you money for over usages and scalling instance.And you can use HTTPS connections too.

I have deployed my application on Bluemix.just have a try since it is free till june month 2014.just share your experience with comments and post errors.Contact with me in s.shivasurya@gmail.com.Share is care.

2 comments:

rahul said...

nice article! shiva....post about mysql db on bluemix also pls!

SHIVA SURYA said...

you can just create service from lists and bind it to ur
particular app! and ur db username,password is given in
ur vcap service

Post a Comment

feel free to post your comments! Don't Spam here!