Migrating to Heroku: WordPress Edition

Update:We have since migrated our systems to Pressable.

Starting the new year we decided to do some spring cleaning. We noticed we had a few instances running on rackspace that were doing next to nothing. Basically only hosting this site. Well it’s time to find a simpler host and close down some older (Ubuntu 10.10) servers.

1st finding a solution.

After a quick look around I found this https://github.com/mhoofman/wordpress-heroku. I have played with this before for some clients but they had a few needs that could not be met. But this site is VERY simple, everything should work great.

2nd Moving your Site

For the purpose of this walkthrough I am going to assume a few things

  • You have an active s3 account with Access and Secret Keys handy
  • You have followed the installation steps for wordpress-heroku
  • You have a local install of Mysql and Postgres

What do we need to do.

  1. Migrate our sites DB toPostgres
  2. Migrate Theme
  3. Upload all wp-content/uploads to s3.

DB Migration Heroku has a fantastic guide here. https://devcenter.heroku.com/articles/heroku-mysql I cheated a bit and migrated directly to the Heroku DB. Here is my config file (not the real passwords but this is what it should look like, my local environment is MAMP)

Once you have your config file set up for mysql2psql run from the directory containing your mysql2psql.yml file.
$ mysql2psql

Themes

Copy your theme to the wp-content directory of wordpress-heroku. Add it to version control and deploy.
$ git commit -a -m "Adding Theme"

$ git push heroku production:masterAt this point the site should be functional, assets should be broken but the admin should work.
FYI: Double check that the url is staying on the heroku url. WordPress may try to redirect you to the WordPress URL saved in the DB.You can add the below code to your wp_config.php to have wordpress respond the to any incoming host and ignore the setting in the DB.
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

Assets

  1. Configure WPRO at Settings -> WPRO
  2. Log into console.aws.amazon.com and navigate to s3.
  3. Navigate to your bucket
  4. Ensure Permissions are set as such. (Everyone List)
  5. Upload the contents of wp-content/uploads to the bucket.

Cavets

  • I have had some issues uploading media from new post window.
  • Using APEX domains on heroku is dangerous and can interfere with mail delivery.

I will update this as I test this more.

Leave a Reply

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