This is just an introduction to how to to Work with open shift through command line.
First of all, 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. The backend of openshift is AWS, the great amazon cloud.
At first create an account at https://openshift.redhat.com
Then install rhc client on your system. Documentation is available [here](https://docs.redhat.com/docs/en-US/OpenShift/2.0/html/Getting_Started_Guide/index.html)
For [Redhat Enterprise Linux](https://docs.redhat.com/docs/en-US/OpenShift/2.0/html/Getting_Started_Guide/sect-Getting_Started_Guide-OpenShift_Client_Tools-Installing_Client_Tools.html#sect-Getting_Started_Guide-Installing_on_Red_Hat_Enterprise_Linux)
For [Mac OS X](https://docs.redhat.com/docs/en-US/OpenShift/2.0/html/Getting_Started_Guide/sect-Getting_Started_Guide-Installing_on_Mac_OS_X.html)
For [Ubuntu, Debian and other Linux systems](https://docs.redhat.com/docs/en-US/OpenShift/2.0/html/Getting_Started_Guide/sect-Getting_Started_Guide-Installing_on_Other_Linux_Distributions.html)
As Ubuntu used by almost all linux geeks around the world, Let me give you the installation steps for ubuntu here.
You must have a sudo / root access of your ubuntu system.
Open a Terminal, and install the pre-requirement packages via apt.
sudo apt-get install git-core ruby1.9.1 rubygems
Now install the rhc client via gem,
sudo gem install rhc
As redhat says,
*–On Ubuntu and other Debian-based distributions, the OpenShift client tools by default are stored in the /var/lib/gems/1.8/bin directory. You must change to that directory and append ./ to each command when running the client tools.–*
But, You can getride of it by creating simlinks.
cd /usr/local/bin/ sudo ln -nfs /var/lib/gems/1.8/bin/* .
Thats it, Now you can call “rhc” commands from anywhere in the terminal.
**Setup your account**
Setup ssh public key authentcation.:- SSH key is used to provide the git access and SSH server access.
Name space :- Your namespace is unique to your account and is the suffix of the public URLs openshift will assign to your applications. See the User Guide for information about adding your own domain names to an application. You must create a domain/namsapce before you can create an application. The syntax for the application name is ApplicationName–DomainName.rhcloud.com.
So your Application URL will be http://appname-namespace.rhcloud.com/ or https://appname-namespace.rhcloud.com/
Lets set the namespace as ‘jobnix’.
rhc domain create -n jobnix -l rhlogin Password:
If prompted, create an appropriate SSH key. Ok now your account has been setup, Lets create an application,
**Create your first application**
mkdir ~/rhcloud cd ~/rhcloud rhc app create -a test1 -t php-5.3 -l rhlogin Password:
This will create a remote git repository for your application, and clone it locally in your current directory.
OpenShift offers many application stacks. Run *rhc app create -h* to see all of your options.
Your application’s domain name will be
Here is my Output
Creating application: test1 in jobnix Now your new domain name is being propagated worldwide (this might take a minute)… retry # 4 – Waiting for DNS: test1-jobnix.rhcloud.com Warning: Permanently added ‘test1-jobnix.rhcloud.com,126.96.36.199’ (RSA) to the list of known hosts. Confirming application ‘test1’ is available: Success! test1 published: http://test1-jobnix.rhcloud.com/ git url: ssh://07a1061d….cc…[email protected]/~/git/test1.git/ Successfully created application: test1
Now my application URL is http://test1-jobnix.rhcloud.com/ It will give a openshift blank page since i didnt pushed anything to the repo.
So lets push my code. From terminal,
cd ~/rhcloud/test1 cd php rm *.php echo “JobNix Test1″>index.php git commit -a -m “First commit” git push
Now i can see my web page at http://test1-jobnix.rhcloud.com/ and https://test1-jobnix.rhcloud.com/
Cool… Please comment if any doubts ![:)](https://www.jobnix.in/wp-includes/images/smilies/icon_smile.gif)