Dan Stutzman

How to deploy to Heroku for the first time

Published 2011-02-23

Heroku is a great way to host your Ruby on Rails web app for free.  The following steps walk you through the process of signing up for an account, creating a Rails app, and deploying to Heroku.  I'll assume you're starting with a vanilla Ubuntu 10.04 install; if not, you can skip any steps you've already done.

  • sudo apt-get update
  • sudo apt-get install ruby1.8-dev rubygems libopenssl-ruby rails git-core
  • ssh-keygen -t rsa # keep hitting Enter to accept the defaults
  • sudo gem install heroku
  • add to ~/.bashrc:
    export PATH=$PATH:/var/lib/gems/1.8/bin
  • . ~/.bashrc # load the new PATH
  • rails myrailsapp
  • cd myrailsapp
  • git init
  • git add .
  • git commit -m "my new app"
  • Sign up for heroku account at https://api.heroku.com/signup, get email, click on link in email
  • heroku create myrailsapp637 # change the name as needed
  • heroku keys:add ~/.ssh/id_rsa.pub
  • git push heroku master
  • vi public/index.html, add some new text before the </body> tag

The Rails app should now be available at myrailsapp637.heroku.com or wherever you deployed it.  For future deployments you can repeat the following steps:

  • Make changes to files as needed; for example, add some text directly before the </body> tag to public/index.html
  • git commit -a # comment about the change
  • git push heroku master
  • Changes should now be visible at myrailsapp637.heroku.com or wherever you deployed to