Sunday, March 17, 2013

Remote Makahiki Installation: A Reader's Guide

After installing Makahiki locally, it's time to try deploying it to Heroku. Once again, I'm following the user manual's instructions for this with a report of how each step went. Install Heroku
Already installed. Add your SSH keys to Heroku
Already done from an earlier project. Verifying your Heroku account
Grudgingly done. I didn't really want to hand out my credit card for this. Setup Amazon S3
Grudgingly done. (Later, in Step 9, I learned I should have selected US Standard as the region for my bucket.) Setup environment variables
As instructed, though I changed the admin password. Download the Makahiki source
Skipped this step, since I still have it from the local installation. Initialize Makahiki
This was probably unnecessary, but: I wasn't sure if this initialization would mess up my existing local installation. I created a new virtualenv with mkvirtualenv makahiki-heroku.

In the next step, I realized I also needed to run pip install -r requirements.txt at this point.

The upload process took about 20 minutes or so. Start the server
Everything loaded fine, but the pages lacked style and images. I checked my S3 bucket and it was empty. Trying again, I found this in the output:
Do you wish to continue (Y/n)? Y
resetting the db...
syncing and migrating db...
Running `python makahiki/ syncdb --noinput --migrate --verbosity 0` 
attached to terminal... up, run.4074
collecting static and media files...
Traceback (most recent call last):
  File "/home/ztomasze/makahiki/makahiki/", line 9, in <module>
    from import execute_from_command_line
ImportError: No module named
s3put -q -a AKIAJC76TME6N23PKRMA -s [...omitted...] -b ztomasze-makahiki 
 -g public-read -p `pwd` media
sh: 1: s3put: not found
s3put -q -a AKIAJC76TME6N23PKRMA -s [...omitted...] -b ztomasze-makahiki 
 -g public-read -p `pwd`/site_media site_media/static
sh: 1: s3put: not found
loading base data...

Both django.core and the s3put commands seem to be missing. I remembered that I had created a new virtualenv, so I ran pip install -r requirements.txt and tried again. Problem solved. Verify that Makahiki is running
The links to images and stylesheets were still failing, even though the files were now in place on S3.

As an example, in the source code of the main page, the logo gif had this URL:

Accessing this URL directly got me this error message:

The bucket you are attempting to access must be addressed using 
the specified endpoint.  Please send all future requests to this 

And indeed, accessing instead worked fine.

Feedback from Yongwen, the current Makahiki admin, suggested that this URL difference is due to which region you select when creating the S3 bucket. I originally went with S3's suggestion of Oregon, but apparently US Standard gives you the URLs assumed by Makahiki. To try this, I deleted and tried to recreate my bucket. There was a temporary name conflict, so I had to choose a different bucket name. I updated the MAKAHIKI_AWS_STORAGE_BUCKET_NAME environment variable and reinitialized Makahiki (step 7).

It looks like everything now works.

Conclusion: Total Time: 3 hours. This was longer than the local install, although there were fewer steps. This time difference was mainly due to waiting for downloads and uploads. Overall, this process was about as painful as any Heroku deployment, though each one gets easier with more practice.


  1. Great write up - clear and concise. How did you get the shaded boxes around the code snippets?

  2. I write my posts in HTML mode. I put the code snippets in <PRE> tags. Then, in my blog's Template -> Customize -> Advanced -> Add CSS, I added:

    PRE {
    padding: 1em;
    border: 1px dotted gray;
    background: #f8f9fa;

    This is easier than installing SyntaxHighlighter.