A few months back I decided to move my blog to Heroku. In this post I have explained how I deployed my WordPress blog on Heroku.
This blog post is the first of the two posts for running WordPress on Heroku. You can find the second post here: Considerations & Workarounds: WordPress on Heroku – 2 of 2 http://www.appcloud101.com/archives/7795
What is Heroku?
Heroku is a cloud platform as a service. You create applications in a language of your choice (e.g. Java, node.js, Ruby, PHP). Then you push your application to Heroku and make it available on the internet. Heroku will provide you with a URL of the form yourapp.herokuapp.com. You can bring your own domain name (e.g. purchase through GoDaddy.com) and attach it to this URL.
So How Do You Learn Heroku?
The fantastic thing about Heroku is that there is nothing new to learn! Simply create your application in whatever language you think is best – and when you are done push it to Heroku. You are live! No need to wade through an ocean of documentation or hire experts to plan your hardware and software strategy.
As you sprint through your application development, make sure you spin up an instance of Heroku to do your testing in parallel. This way you will get familiar with all the knobs and pulls in Heroku and at the same time ensure that the bugs in your application are weeded out continuously.
Can you migrate an app which you have already created and run elsewhere to Heroku? Absolutely!
Get Started with Heroku
List of software needed: MySQL Database, Apache Webserver and PHP 5.2 Runtime. Linux. WordPress.
Note – I decided to get the official binaries from wordpress.org not the pre-created builds for Heroku. I am not a fan of installing packaged code from unverified sources; apart from the fact that these builds may run into future upgrade & plugin compatibility issues.
A word about databases. Heroku supports different database flavours including Postgres, MySQL, Graph DB, Hadoop clusters and others. I chose MySQL simply because my local development system runs MySQL and I have some good tools to manipulate it.
You can run your WordPress blog on Postgres as well. In many cases Postgres on Heroku may be a good choice – Postgres supports technologies like Heroku Connect, External Objects and more for easy integration with your Salesforce org and other systems.
My Dev environment: WAMP on local host, a local staging directory and the remote Heroku cloud.
I run WordPress on my local Windows 2007 server using WAMP for development and local testing. WAMP simply gives me an easy installation of Apache, MySQL and PHP. You can download these and install separately also.
For enterprise apps you would most likely use a Dev instance of Heroku itself for development or testing.
To deploy to Heroku, I first copy my files to a local git directory. Here is where I make changes to the files – I use notepad++ to find and replace all www.appcloud101.com references to my custom domain reference (technologyformanagers.com). I then push my changes to Heroku; and then on the remote MySQL database I again use a SQL query to find and replace all www.appcloud101.com references.
The changes to database I could have done locally also, but I would have to maintain a separate database locally (not a big deal).
My Mobile & Social Strategy
I decided not to create a native/hybrid app, nor even a responsive site – for now. Instead, I created a site which looks equally good both on mobile and web, with large fonts and minimal navigation button. With the growing size of pocket devices and my desire to get the site out quickly this seemed the best plan of attack. A mobile app is coming though, stay tuned!
I used social media groups (FB Groups & Pages, Google groups & LinkedIn Groups) for creating community of users around specific activities. As an individual blogger that works great for me. For enterprises, I would recommend leveraging Salesforce Communities.
For comments, instead of native WordPress comments, I use OAuth 2.0 to integrate with Facebook and Twitter so you can comment on posts and also share posts. I did not use any of the commenting & social login web services like Janrain, Gigya and Disqus. One – these are very expensive for what they do. Second, I don’t need users to login in to my site.
Trends which inspired me
As a general trend in CMS, many sites like Copyblogger have decided to do away with commenting all together for various reasons. You can visit their site to read about it. Many people are questioning the authenticity of hundreds of comments on many sites today.
All in all, engaging people through comment system is not my top priority. Providing real value knowledge which you can use is my top priority. If you have questions or comments, tweet them out to me, or engage with me on other better QA platforms like Stack Exchange.
Why Did I Choose WordPress?
I have worked a lot with other portals also known nowadays as “User Experience Platforms” – Liferay (Java), Oracle Webcenter Suite 11g (Java), Drupal (PHP), Ghost (PHP), Microsoft SharePoint (.Net). For now I am sticking with WordPress though my long term roadmap is to migrate to Liferay.
Why Did I Choose Heroku?
First of all, I chose Heroku for my personal blog because I wanted to play with this amazing platform. Heroku makes my internet presence easy while giving me enterprise grade service.
There are some IaaS providers who claim to be elastic, automated cloud platforms – but in my humble opinion, no one today provides the unique blend of enterprise grade service with complete automation like Heroku does.
Ultimately the benefit of Heroku lies in how it eliminates the need for infrastructure & Dev-Ops allowing you to focus on innovation.
How Do You License Compute Power?
You need processing power, file storage for your applications files and database for your application’s data. In Heroku, you license units of computing power called Dynos – each dyno has a certain amount of memory and CPU associated with it. When your application becomes popular and more people start accessing it, use the Heroku DX dashboard to increase the number of dynos for your application. Heroku is designed as an elastic cloud, you can decrease the amount of dynos for those times when you don’t need much compute power. Also, you can license database service as an add-on.
How Does Heroku Run My Apps?
Celadon Cedar-14 is Heroku’s default runtime stack and is a flexible, polyglot environment.
Polyglot support means that you can use many languages across and within my projects.
Include a Procfile with your applications to tell Heroku what to run. A Procfile is a text file in the root directory of your application that defines process types and explicitly declares what command should be executed to start my app.
Check Heroku docs for application specific tips – for example, for PHP apps, include a file called composer.json in the root directory of my app; using this file you can specify things like the version of PHP runtime you want from Heroku.
What’s happening inside Heroku? While Heroku does a lot in the background, you have complete visibility to what’s happening. Here’s how you can get info about what’s happening in your application: https://blog.heroku.com/archives/2011/6/24/the_new_heroku_3_visibility_introspection
Ok, So How Do you Become an Expert in Heroku?
There is no need to ‘learn’ Heroku. All you got to know is how it works conceptually, how to add database, the ephemeral nature of its file system etc. Then you develop in whatever language you love and push your app to Heroku using the cheat sheet link I have mentioned in this article.
While you can do a lot, if not everything, from command line interface (CLI) – it would be inefficient not to take advantage of the great new Heroku DX dashboard. That is why I am suggesting in the cheat sheet to do things (like create an app) on the Heroku DX dashboard and not through CLI. Use the Heroku DX as much as you can: https://dashboard.heroku.com/
This post with WordPress on Heroku tips is not an official guide from Heroku. Please make sure that you try it in a “crash and burn” environment only. Refer to official Heroku guides on Heroku.com.
Here’s the Heroku Cheat Sheet for you: http://www.appcloud101.com/archives/4112
Here are some things to keep in mind while deploying WordPress on Heroku: “WordPress on Heroku Considerations” http://www.appcloud101.com/archives/7795