, , , , , , ,

Recently cloud word is a buzz. So what is actually cloud hosting means? Well I can simply say that “Cloud Hosting is web hosting where more than one server is used as a host.” If you are interested for more info google is your best friend 🙂

By the way recently I tried appfog and openshift for my personal blog. Today I’m going to introduce you with openshift. Well you may ask why I’m not talking about appfog? There’s a reason behind this I’ve hosted my main domain smronju.com in appfog but when I tried to do host my blog there I wasn’t allowed to add a sub-domain. They recently made that feature paid! Okay then let’s begin.

OpenShift is Red Hat’s Cloud Computing Platform as a Service (PaaS). Now click here and register in openshift. Before we go forward we have to configure our PC working with their Command Line Interface (CLI).

Installing client tool
Open terminal and run below command as follows. If you are a mac user please update your ruby and rubygems then install rhc also make sure that you have git installed.

$ sudo gem install rhc
$ sudo rhc setup

Ubuntu or Linux user run below commands in terminal.

$ sudo apt-get install ruby
$ sudo apt-get install rubygems
$ sudo apt-get install git
$ sudo apt-get install rhc
$ sudo rhc setup

Creating a domain and an application
After installing the OpenShift tools, the next stage is to create a domain name to host the application in and the applicaition itself. You can also create do this from their web site as well. Okay so for creating a domain is achieved with the rhc domain create command.

$ rhc domain create -n <domain> -l <emailaddress>
Note: <domain> = smronju or whatever you like and <emailaddress> = email address you register with.

Next, we need to create an application. For wordpress we will create it from their web page cause they already have some Instant App. This will create your application and adds “cartridges” for you. Well this can be done via command line as well.

$ rhc app create <myapp> php-5.3
$ rhc cartridge add mysql-5.1 -a <myapp>

But this will only create a basic php openshift app with mysql. Rest you have to do manually. That’s why we choose Instant App creation.

Okay now follow these steps for creating an Instant App. I assume that you already logged-in in openshift now click on Create Application If you don’t have any apps you will be there automatically.


Click on wordpress

02Give a application name and then click on Create Application. On the next page you will get mysql database info, an url for accessing your wordpress blog, and git repo url. I will get back to you about git later.Step-03aStep-03bStep-03cAt this point we have an wordpress application. Now click on the application link and setup your wordpress as you do normally. Provide necessary info here and click Install WordPress.

wordpress-setupIf everything goes as expected you may now login to your wordpress admin section and congratulation you did it.

Okay now come back to the git point I mentioned earlier. This is the fun part you can use git updating your application or the blog we just created. Clone the repo in you local machine and commit your changes it will upload the changes to your app. Isn’t it nice with openshift? Well there’s a small issue with openshift every time you push local code to openshift. Unfortunately if you do any modifications on the server will be lost. To overcome this make sure that you only make changes locally and push them to openshift. This also applies for installing plugins to WordPress – always install them locally. Also, any images uploaded to WordPress (by default stored in wp-content/uploads) are also lost when you push new code. For this make sure you added following content in /.openshift/action_hooks/build file:

if [ ! -d $OPENSHIFT_DATA_DIR/uploads ]; then
mkdir $OPENSHIFT_DATA_DIR/uploads

ln -sf $OPENSHIFT_DATA_DIR/uploads $OPENSHIFT_REPO_DIR/php/wp-content/

Lately I found that it’s already there and is added by openshift 🙂

Publishing to a custom domain
Now if you want to map your domain instead of rhcloud.com like I did for my blog with blog.smronju.com 😉 Run this command in terminal

$ rhc alias add <myapp> <blog.yourDomain.com>

To complete the process, you need to edit your DNS records and add a cname pointing your domain (e.g. blog.yourDomain.com) to <appname>-<domain>.rhcloud.com

That’s it thanks for reading.