Configure WordPress on OpenShift without Git: Part 1

I wanted to move a WordPress site from a shared host to a OpenShift, the PaaS offering from RedHat. This should be a faster setup since the OpenShift gears will be dedicated to just this one site. However, OpenShift is focused on developers and by default expects you to install command-line tools and git version control to be able to create and update your site. Their WordPress sample sites loads easily enough, but includes a non-standard directory structure that might cause trouble with uploads and restores.

So how do you create a “standard” WordPress site on OpenShift? This two part article will show you.

Part 1:  Set up the OpenShift application and access it remotely.

Part 2:  Set up WordPress on the OpenShift application.

OpenShift has a helpful article, 12 Tips for Hosting WordPress on OpenShift, that I refer to below.

Set Up the OpenShift Application

1. At the Welcome page, click Create your first application now.

2. Do not create a WordPress instant app. Instead, create a PHP 5.4 app.

3. On the Configure the application page:

Public URL: mysite – mydomainroot . rhcloud.com

Scaling: Scale with web traffic (so SQL can be in a separate gear, per Tip 2 in the 12 Tips article)

Region: aws-us-east-1 (the only option for small gears)

Click Create application.

4. Will you be changing the code of this application? Not now, continue.

5. Your new application screen will open with the PHP 5.4. and Web Load Balancer gears showing.

WordPress on OpenShift 1

Under Scales, click on the 1-3 link. Change it to scale to a Maximum of 1 small gear.

6. Back on the application page, under Databases, choose Add MySQL 5.5. On the following page, click Add Cartridge. Copy and paste the SQL credentials.

Note that if you try to add phpMyAdmin, you’ll get this message:  “phpmyadmin-4 cannot be embedded in scalable app….”

7. At your DNS provider, create the CNAME record for your new web site. For example, new.mydomain.com points to mysitae-mydomainroot.rhcloud.com.

8. Back on the application page, next to the application’s URL at the top, click Change. Set the app’s alias to match the previous step, e.g. new.mydomain.com.

Access the App

You’ll need an SSH key pair to get access to the site using PuTTY and WinSCP. (These instructions assume you are working in Microsoft Windows.)

Set up an SSH Key Pair

There are details in this article about using PuTTY. Unfortunately they assume you are using OpenShift’s rch setup, which requires installing OpenShift tools. That’s not necessary.

1. Install PuTTY. Use the full Windows installer so you get all modules.

2. Open PuTTYgen and generate an SSH-2 RSA key with 2048 bits. Or if you already have a private key, click the Load button and load it.

3. Update the comment if you want.

4. Save the the private key on your computer.

5. At the top of the Key Generator, under Public key for pasting into OpenSSH authorized_keys file, copy the contents of the text box to the clipboard.

6. In the OpenShift application page, on the right under Source Code, click on the link add an SSH public key to your account. Give the key a name, perhaps matching the key’s Comment, paste in the contents, and click Create.

That’s it for the keys. You now have an SSH link to your OpenShift app.

Add the App to PuTTY

PuTTY gives you command-line access to your PHP server.

1. In the OpenShift application page, on the right under Source Code, you now have a long string that includes the host name you need for accessing the site, e.g.

ssh://[email protected]/~/git/mysite.git/

You need to extract the section shown in bold. Copy it to your clipboard.

2. In PuTTY, paste the text you extracted into the Host Name field.

3. In the left pane, navigate to Connection > SSH > Auth. In the right pane, click Browse to find your private key file.

4. In the left pane, click on the first item, Session. Under Saved Sessions, type a new name, e.g. “mydomain.com at OpenShift”. Click Save.

5. Click on the Open button. You’ll be asked if it it okay to save the host’s key. Click Yes.

Going forward, you can load your saved site and connect immediately. Because you have the private key that goes with the public key on OpenShift’s server, you do not have to type a password (unless you password-protected the private key).

Add the App to WinSCP

I like WinSCP for easily visualizing and manipulating files on a Linux host.

Have your PuTTY “Host Name” available (see above).

1. In WinSCP, in the left pane, highlight New Site.

2. In the right pane, set up these values:

File protocol: SCP

Host name: the part to the right of the @ sign in your PuTTY host name, e.g. “mysite-mydomainroot.rhcloud.com”. Do not include the @ sign.

User name: the part to the left of the @ sign in your PuTTY host name, e.g. “1234a5678b9012c2345d6789”. Do not include the @ sign.

Password:  leave this blank.

3. Click on Advanced. Under Enviornment > SCP/Shell, choose “/bin/bash”.

4. Still under Advanced, choose SSH > Authentication. Under Private key file, browse to the private key your set up above. Click OK.

5. Back on the main window, click Save. Give the site a name, e.g. “mydomain.com at OpenShift”.

6. Click on the Login button. You’ll be asked if it it okay to save the host’s key. Click Yes.

Going forward, you can just highlight your saved site and click Login.

Add the App to FileZilla

I mostly use WinSCP for updating files on a Linux host, but it is possible to set up the FileZilla FTP client to establish an SSH session. You can run a PuTTY-provided program called Pageant (haven’t tried that) or you can provide a non-password-secured key under Edit > Settings > Connection > SFTP, then Add keyfile. Then set up the site using the same Host and User that you used for WinSCP. See this article for more details.

Continued in Part 2

See Part 2 of this article for instructions on restoring your WordPress site to your new OpenShift application.

6 thoughts on “Configure WordPress on OpenShift without Git: Part 1

  1. Kiuhnm

    Very useful article. I used the automatic installation of WordPress and I wasn’t able to restore my website from a backup I made (it always worked on regular hosts). Now I’m trying to reinstall WordPress manually with your method. I hope it works!

  2. Pingback: Configure WordPress on OpenShift without Git: Part 2 | MCB Systems

  3. Antony

    Every time I set up WordPress on OpenShift, it works fine…but the very Next Day, I Get a whole lot of Error messages that Plugins & Theme files are Missing…
    I’m on the Free Tier Plan. Ive assigned 2 Gears for PHP 5.4 and 1 remaining Gear for MySQL 5.5
    By the way..as you had mentioned, I was not able to add phpMyAdmin 4.0
    Got stuck up right now….
    Can you please suggest an idea how to Fix it?
    Since I’m not a Pro… [No idea how to use Git or those Linux Commands], is there any easy way to set up WordPress and not lose my customization every single Day?

    Hope you’re able to Find me a Fix. Any help would be Appreciated. Thanks.

  4. Tom

    Hi,
    Is the anyway that I can add the ‘phpMyAdmin’ to the application, I really need it. I have another OpenShift account that I can add ‘phpMyAdmin’ but not the new one.
    Please show me how, thanks.

  5. Mark Berry Post author

    Tom, you will have to set it up manually. It’s been a while since I did it so I don’t remember the steps, though I remember it wasn’t easy. Here is a comment from part 2 of this article (https://www.mcbsys.com/blog/2015/05/configure-wordpress-on-openshift-without-git-part-2/): “I did get phpMyAdmin working but I created a separate subdomain mysql.mydomain.com. That requires some advanced configuration in .htaccess. Then phpMyAdmin itself must be configured for login methods etc. I seem to remember this involved creating config.inc.php in the phpMyAmin main folder. Maybe this setup article will help: http://docs.phpmyadmin.net/en/latest/setup.html.”

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.