As a web developer, I have a strong tendency of building everything by myself. That’s why when I started my personal website, labsterx.com, I built the whole thing, including a blog system, all by myself using PHP. But later on I started realizing the power of WordPress and eventually decided to migrate my site to be WordPress based. One decision I had to make is: where to host this WordPress site? Eventually I choose to host it on OpenShift. The reason is quite simple: OpenShift provides a powerful server (I would say it’s much better than those of shared hosting services) and it’s FREE!
UPDATE:
OpenShift has stopped offering free hosting account that you can use to set up WordPress. Therefore, this article no longer applies unless you have an existing OpenShift free account. For anybody looking for a WordPress hosting provider, you can consider WPEngine and StudioExpress.
What Is OpenShift
For anybody not familiar with OpenShift, it’s an open source PaaS service provided by Red Hat, similar to Amazon AWS. OpenShift’s hosting platform makes it easy to run container-based web application in the cloud, and it has a free tier, which has enough power to create a WordPress site. While AWS only offers 1 year of free usage, OpenShift’s free account doesn’t have a time limit (at least for now) and it doesn’t require a credit card to sign up. You can deploy many different stacks to OpenShift, including WordPress.
The Pros and Cons of Hosting WordPress on OpenShift
For running an independent WordPress powered website (not like http://myname.wordpress.com), people usually use low-cost shared hosting service, such as bluehost, hostgator, dreamhost etc., or use specialized WordPress hosting services such as WPEngine etc. Bigger companies might choose to host their WP sites on their own server or with a cloud hosting service. One big advantage of hosting WordPress on OpenShift is that it can be done truly free. For a free account with OpenShift, you get 512MB RAM and 1GB storage. You can use your own domain name for your WP site. According to OpenShift, basically the free account is good enough to run a WordPress site with hundreds of articles. It can handle up to 15 page views per second, and up to ~50k visitors per month. In addition, you can use the free W3 Total Cache plugin and CloudFlare’s free DNS service to further speed up your site. With CloudFlare, you can also set up SSL for your WP site for free.
OpenShift uses the concept of gears to refer to computing power and resources. The free account comes with 3 small gears. In order to handle more traffic, you can upgrade to a paid account, which offers more or bigger gears. Also, OpenShift supports application scaling, which can be enabled to automatic handle web traffic spikes.
If you have a small personal site that don’t expect big traffic, then you can host it on OpenShift for free. Even if you are not a technical person, you can set up WP by yourself and run this site without too much trouble. Just make sure you don’t enable advanced options such as scaling. After WP has been set up, writing post, installing plugins etc. can be done pretty much the same way as with other hosting services.
However, if you expect more traffic later on and want to use advanced features such as scaling, you do need to have some technical skills to host WP on OpenShift. You need to know how to run command line to do source control and deploy code. Are you familiar with the word “git”? Have you ever used git to pull and push code before? If you have no clue what I’m talking about, then probably you won’t be able to use the advanced features for OpenShift.
If you have no problem using git and deploying code, there’re still a few things that you need to know. If you decide to enable scaling for your WP site, then you can’t use the WP Admin web interface to install and update themes and plugins. You must update your code repository to do so, otherwise your updated themes or plugins won’t be deployed to all of the gears dedicated for scaling. Also, if you want to enable scaling with more than one gear, for uploading media files (images and videos), you can’t use the WP admin web interface to upload them directly to the server. Instead, OpenShift suggests installing a WordPress plugin that stores all media files to a third party service such as AWS S3 or Dropbox.
Another thing is, if the WP site hosted under your free account doesn’t receive any visit for some period of time, then OpenShift might pause your site and might eventually delete your application if it has been idling for too long. Some people has been using free services such as Pingdom to send automatic visits to their site to avoid this kind of situation.
Also, OpenShift’s free account doesn’t come with an email server. WordPress relies on email sending for user registration and password reminder delivery. By default, such emails will have a sender address like [email protected], which tends to be delivered to people’s spam folder. OpenShift suggests using third-party email services such as SendGrid (can be signed up and used for free) to handle emails.
OK. If you have decided to use OpenShift to host your WordPress site for free, now let me go over the steps in the following step-by-step tutorial:
Sign up a Free Account with OpenShift
First you need to get a OpenShift hosting account, which can be signed up for free. Go to the OpenShift website and click on “Sign Up For Free” and then follow the sign up process. You will receive a confirmation email with links to verify your email address. Click on that link to verify.
Create a New App at OpenShift
Once your email has been verified, you will see a welcome page like the picture shown below. Click on the link “Create your first application now”.
Then you will see a collection of instant apps you can set up. Select “WordPress 4” (or the newer version if you are reading this article from the future).
Then you will be asked to set up the public URL for your WP site. Note this is not your mydomain.com kind of URL, but a subdomain URL that each OpenShift app needs to have. Let’s say you have your own domain name (mydomain.com) you would eventually use, then you can name the first part “wp” and the second part “mydomain”. Based on this configuration, OpenShift will create an unique public URL http://wp-mydomain.rhcloud.com for this new app. If you don’t have your own domain and are happy with a rhcloud.com subdomain, then you can use this URL for your site. If you do want to use your own domain, in the following steps your can set it up by adding alias to your application.
Note that down below there’s an option for “Scaling”. If you are not an advanced user (meaning you don’t want do use command line and git etc. to deploy code) or you don’t expect heavy traffic to this site, you should leave it as “No scaling”. If you are a techie and expect more traffic, then you can change it to “Scale with web traffic”. Please note that by enabling scaling, later on you won’t be able to do theme updates and plugin updates using the WP admin web interface, but must do so in your code repository. After that, click on the “Create Application” button near the bottom of the page. It might take a few minutes to get your first app created. Don’t lose your patience.
When this process if done. You will see a message asking “Will you be changing the code of this application?”. Just click on “Not now, continue”.
Then you will see a summary of your newly created WordPress app like this picture:
The most important part of this summary is the URL on the top. If you do not want you use your own domain and are happy with this URL provided by OpenShift, then that’s your final URL. If you want to set up your own domain name, you will need to change it soon.
Now, if you have selected “Scale with web traffic” during the previous step, let’s click on the link “1-3” under “Scales” in the PHP 5.4 part under “Cartridges”. When a new option page shows up, leave the “Minimum” as “1” and change the “Maximum” to “1”. This will simply the process of running this site so that you don’t have to worry about complicated situations with scaling.
To go back to the application console for your newly create site, you can always click on the “Application” link on the top navigation bar and the click on the link below (in this example called “wp”) as in this picture:
If you don’t want to use your own domain, then that’s pretty much it. Just click on the URL for your new app and follow the typical steps for WordPress initial set up.
If you need to use your own domain, then please keep going and do the followings.
Set up Domain Name for WordPress Hosted on OpenShift
On your app summary page, next to your URL, there’s a small link “change”. Clicking on that link will take you to a page where you can set up your own domain name (referred to as “Alias”) for this site:
Note that there’re TWO parts in accomplishing this:
First, you need to set up a CNAME record with your DNS provider (such as Godaddy or other providers). If you don’t know how to do this, click on the link “Set up the CNAME record with your DNS provider” on this page for instructions.
Secondly, you need to add your domain name to the OpenShift page (as shown on the picture above).
There’re some considerations for setting up domain names. In most cases, you might want to use both http://youdomain.com and http://www.yourdomain.com for your WordPress site. If so, you should do the above steps TWICE, one for www.yourdomain.com and one for yourdomain.com (OpenShift allows you to set up multiple alias for a single app). Note that for setting up yourdomain.com with your DNS provider, you need to delete any existing A records for that domain and create a CNAME “yourdomain.com” and point it to your OpenShift app URL. At the same time, some people might only want to set up this WordPress site on a subdomain, www.mydomain.com or blog.mydomain.com. In this case, you only need to do it once.
After you have set up the domain name, just visit http://www.yourdomain.com in your browser. Then you can follow the typical WordPress set up process to finish setting up your new WordPress site. Don’t forget to change the site URL to your own domain name under Settings > General.
If you don’t want to touch advanced features such as scaling etc, then that’s pretty much it. You have a WordPress website hosted on OpenShift and you can take it from here.
If you are an advanced user, then let me briefly go over the additional steps:
Set up Local Git Repository
The goal is to set up a local git repository, which allows you to make changes and then deploy the changes to the OpenShift server.
First you need to set up your public key in the OpenShift application console. Once that’s done, you will be given a URL for git clone (see picture below):
Use this URL and git clone the code repository to your local machine.
Once you have a local repository, open up the code tree and let me point out a few important directories and files (see picture below):
The most important directory is a hidden directory called “.openshift”, which is pretty much the only directory that you will work with.
Under this directory, there’s a “config” directory, under which you can find the “wp-config.php” file. In case you need to mess with some WP configuration stuff (such as adding your SendGrid API credentials or turning off forcing SSL for admin panel etc.), you can do it here.
Under the “.openshift” directory, there’s a “plugins” directory, which is the place for putting all of your plugins.
Also under “.openshift”, there’s a “themes” directory. That’s where to store your theme(s).
Usually, the first steps after cloning the repository would be setting up your themes and plugins. Download necessary plugins and themes and put them into the “plugins” and “themes” directories, respectively. Then you can use “git add”, “git commit” and “git push” commands to deploy your changes to the OpenShift server.
In the future, when it’s necessary to update your themes or plugins, you need to first update the local repository and then deploy the changes to the server.
For more tips and tricks, you can take a look at this article provided by OpenShift.
Conclusion
You can host a WordPress website free of charge on OpenShift, an open source PaaS service by Red Hat. It’s truly free and can be set up using your own domain name. The free hosting is good enough for small or personal sites without big traffic. OpenShift does offer advance features and upgrades to handle more traffic. To take advantage of the advanced features (such as scaling), some technical skills are required to set up and maintain the site.