Thursday, February 13, 2014

Hosting Static Site on Heroku by Michael Droz

Heroku is the preferred hosting solution for Rails apps but what about hosting static sites? No problem of course, but you do have to know the trick. I spent about 15 minutes figuring it out which is probably an indictment on me and not the good folks at Heroku. Below is a step by step guide. 

Motivation: Hosting a static site as an example of html/css skills. 

Prerequisites: 
  • Git installed and configured 
  • Heroku account
  • Heroku's Toolbelt installed 
  • SSH generated and associated with your Heroku account

Step by step guide: 
1. mkdir michael_droz_static_site
2. cd michael_droz_static_site
3. git init
4. copy files into new directory (or clone from remote)
5. (this is the trick) create simple php file named index.php with the single line 
<?php include_once("home.html"); ?>

6. rename index.html to home.html
7. git . add
8. git commit
9. heroku create
10. git push heroku
11. heroku open (this will open a browser to your new site)

If you want to rename the site you simply issue the following command:
heroku app:rename michael-droz     

Here's a link to the site I created: 

   

No comments:

Post a Comment