Locked lesson.
About this lesson
Exercise files
Download this lesson’s related exercise files.
Hosting Your App On Heroku.docx59.7 KB Hosting Your App On Heroku - Solution.docx
59.5 KB
Quick reference
Hosting Your App On Heroku
We'll host our app on Heroku; which is a production quality web hosting service that has a free tier.
When to use
C9 allows us to run a simple web server that will give us a public URL and website, but it doesn't have the horsepower to allow many people to view that web site at once. So we need real webhosting to host our app professionally. Heroku is the answer.
Instructions
Sign up for Heroku for free at Heroku.com
At your C9 terminal, issue this command to make sure the Heroku toolbelt is installed:
- heroku --version
To Connect your C9 account with Your Heroku account, issue this command from your terminal:
- heroku login
Enter your heroku email and password when prompted.
Next, add your SSH keys to heroku by issuing this command from the C9 terminal:
- heroku keys:add
Next, create an app on Heroku by issuing this command from the C9 terminal:
- heroku create
Be sure to write down the URL that the terminal spits out at you.
Next, we need to make some changes to our Gemfile to move the sqlite3 database into development only, and add Postgres database to production.
Open the Gemfile and remove the line:
- gem 'sqlite3'
and add it to the Gemfile Section:
group :development, :test do
gem 'sqlite3'
gem 'byebug'
end
Next add this code to the Gemfile to add the Postgres database to our production environment (heroku):
group :production do
gem 'pg'
end
Finally, from the terminal, type in this command:
- bundle install --without production
Finally, we need to push all our code to heroku. From the terminal, type these commands:
- git add .
- git commit -am 'added PG'
- git push
- git push heroku master
Hints & tips
- Heroku is a production quality web host
- Heroku offers a free tier that we'll use in this course
- We push code to Heroku in much the same way that we push code to github, from the terminal
- Heroku requires the Postgres database, so we need to make a small change to our Gemfile
Lesson notes are only available for subscribers.