I recently read a few articles on how to deploy a wordpress blog on heroku. Interesting idea I thought. So how do we go about doing this ? Heroku recently announced their partnership and integration with Facebook Apps. Along with this announcement, or perhaps at an earlier time, Heroku’s Celadon Cedar stack can detect and support PHP applications. Although heroku says you can only create PHP application from Facebook that’s not entirely true.
There are ways to deploy wordpress (a PHP application) on Cedar stack of Heroku. In fact this blog IS running on wordpress hosted on heroku.
Here is how.
Assuming you have the Heroku gem and an account set up, create an empty project directory:
Download the latest repository from wordpress -
tar xzvf latest.tar.gz;
Copy wordpress directory content to 'wp_blog' directory created earlier. Now you are ready to push the code to git.
git add .
git commit -am "Initial checkin"
Create your heroku app with Cedar stack
heroku create --stack cedar
git push heroku master
Now comes the most critical part. Heroku has a MySQL cloud database addon (Xeround) as an option but that is not open for all. But you can still use the default Postgres database support using Postgres WordPress plugin which allows the use of Heroku’s shared database as an addon.
Enable shared Postgres database support:
heroku addons:add shared-database:5mb
Check the database parameters from heroku's environment:
DATABASE_URL => "postgres://username:password@hostname/database"
Now, you can edit wp-config.php with the details from the DATABASE_URL entries. Make necessary changes to wp-config.php and push the modified to heroku.
One small thing is that you can not install plugins/themes using the normal methods because Heroku stack does not have the zlib support. You will have to download plugins and themes locally and push to heroku. Big deal...?