How to create a WordPress site on OpenShift

OpenShift is a platform similar to Heroku that allows developers to easily create application hosting environments with a few clicks or commands. In this post I’ll be running through setting up a basic WordPress site on a free OpenShift application “gear”.

Basic Setup

  1. Create a free OpenShift account, verify your email and accept the terms. You’ll now be on the OpenShift Web Console’s welcome page.

    Create an account   OpenShift Online by Red Hat

  2. Click “Create your first application now” and choose WordPress from the OpenShift-maintained starter applications.

    Create a New Application   OpenShift Online by Red Hat

  3. In the “Public URL” section choose your application name (e.g. production or staging) and namespace (e.g. yourwebsitename).

    Create a New Application   OpenShift Online by Red Hat 2

  4. Note that the “Source Code” section includes a URL to OpenShift’s WordPress starter application. This will be the base code for your application and is ready to deploy to OpenShift.
  5. Leave the remaining options as their defaults and click “Create Application”. This will create your hosting environment “gear” and deploy the starter application code to it. Your application should now be accessible at http://appname-yourwebsitename.rhcloud.com/.

    Application Overview

Managing the Code

Your application’s code is managed in a git repository on OpenShift’s servers. To gain access to push and pull changes you’ll need to add your computer’s public SSH key to your OpenShift account. A good way to achieve this is by setting up the OpenShift Client Tools, and then we can clone the application to your computer.

  1. Follow the instructions to install the OpenShift Client Tools for your operating system.
  2. Follow the instructions to sign in to OpenShift from the client tools for the first time. This process will add your computer’s public key to your OpenShift account, creating one if necessary.
  3. You now have access to pull a copy of your application’s git repository to your local machine. On the application’s overview page in your OpenShift Web Console you should now see the URL to your application’s repository. Something like: 

ssh://84hf4f4d89f5cf3679830735@-.rhcloud.com/~/git/.git/

    Source Code URL

  4. Clone this repository to your local machine using git or add it as a remote if you’ve already got a repository (hosted on GitHub for e.g.) for your site’s code. Note that if you take this second approach you’ll need to merge in the code from your new OpenShift repository and update your existing site’s structure to match the WordPress starter application for it to deploy successfully to your OpenShift gear.
  5. You can now work on your website locally however you wish, a common approach is using MAMP to run WordPress on your machine which works well with a development workflow like WordPress Gulp. When you want to deploy changes simply push to your OpenShift repository and your changes will be deployed to the gear.

Leave a Reply