Actually in my opinion this is one of the simplest ways to get your WordPress blog/site
up and running in no time. in just few simple commands you have a Blog in the air that
you can customize and edit to you liking. I am counting that you already have created your
own OpenShift account and installed the rhc Client Tools. If not please head to my
Guide: Introduction to Openshift hosting Apache Tomcat post and follow the first two
paragraphs to open the account and install the tools. I would recommend to read all of it
as it holds great information regarding tools that will simplify your work with OpenShift.
Now you are ready to create our own WordPress application container on OpenShift.
Open your command prompt and head to the location were you want your git repository
for this project to be created and enter the following command:
rhc app create -a <name for your container> -t php-5.3
Name your application container as you wish. This name will be part of the URL for accessing your application.
So now we allocated resources to ourselves in Red Hut’s cloud with php 5.3 application
already installed. WordPress needs a database to store it’s data and can’t live without
it so we will add MySQL database to this configuration using the next command:
rhc cartridge add -a <name of your container> -c mysql-5.1
And finally I always add the phpMyAdmin application to make it easier on me to manage my
databases. To do that run the following command:
rhc cartridge add -a <name of your container> -c phpmyadmin-3.4
Save your database credentials produced at the end of this process.
Now we are ready to install WordPress. There are two ways you can do that:
1. The first and the easy way to get a WordPress installation is to pull it from a git repository.
Head to your application folder using the next command:
cd <name of your container>
Now set the remote git repository to pull it’s stream from it:
git remote add upstream -m master git://github.com/openshift/wordpress-example.git
Pull the stream/content:
git pull -s recursive -X theirs upstream master
And push it to your repository on the cloud:
To access your WordPress application use the default credentials:
User name: admin
The problem is that the version of WordPress now hosted on this repository is 3.4 and there
is a new 3.5 WordPress installation available. You could upgrade your WordPress version
using it’s Dashboard interface, but now you will have 2 different versions of WordPress
on your local git repository (3.4) and the clouded one (3.5). I will explain how to fix this
problem in the update section.
2. Alternatively you could push you own WordPress installation to your cloud repository.
Head to www.WordPress.org and download the latest version of WordPress.
Copy the downloaded content to the php folder in your local repository and open the
command prompt. Head to your local git repository folder and enter the following command:
git add .
For letting git know of all the changes that were made to that folder, then:
git commit -m "added wordpress3.5"
Committing the changes to the local repository. And finally Pushing the changes to the cloud:
And that’s it, now you can access your new WordPress application using the URL
you are provided on OpenShift and start customize it.
Updating your local repositry with the changes made by WordPress in the cloud:
When you will update you WordPress installation in the future or maybe you would want to
change the looks of your blog/site by adding a sleek Theme or maybe a Widget and you’ll do
that using the Dashboard interface, you would have to update your local repository with
those changes. In that case what you need to do is to take a snapshot of your machine on
OpenShift using the next command:
rhc snapshot save -a <name of your container>
this will download a <name of your container>.tar.gz to you local git repository
containing a snapshot of your files from the clouded repository. Extract the files to a folder
with the same name and head to:
<name of your container>\<your OpenShift ID>\app-root\repo\
Copy the content of this folder to your local git repository folder and commit the changes
using the following commands:
git add .
git commit -m "wordpress updated"
That way the files on your local repository will be identical to those in the cloud.