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.
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.
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.