Greetings :)

Hi, I'm Louis!
I like to code, but I don't do enough of it.

This blog is about trying my best to keep up with the ever evolving stream of technology.

Saturday, September 24, 2011

Adding local 'DNS' entries to your mac

I'm currently working on adding subdomains to my sinatra app - following the instructions at:
http://tannerburson.com/2009/01/extracting-subdomains-in-sinatra.html

First we need to add a local domain name to our hosts file:
http://decoding.wordpress.com/2009/04/06/how-to-edit-the-hosts-file-in-mac-os-x-leopard/

  • sudo vi /private/etc/hosts
  • Run dscacheutil flushcache


Once this is done, wildcard subdomains will need to be supported. I'm using Heroku, and thus I'll follow the instructions at http://devcenter.heroku.com/articles/custom-domains

Heroku notes

Create a new heroku instance

gem install heroku
heroku create
git push heroku master

>> 'successfully deployed' then you go to the site and ... error...

heroku logs

>> figure out the error (e.g. missing gem.. update Gemfile) then try again...

now that we've got something running, can add a domain...

(taken from http://devcenter.heroku.com/articles/custom-domains)
heroku addons:add custom_domains
heroku domains:add www.example.com
heroku domains:add example.com

And now setup domains on your domain provider (I'm using godaddy)

75.101.163.44
75.101.145.87
174.129.212.2
In GoDaddy find your domain name, click on it, and then click the 'DNS Manager' on the page that shows all the information about your domain. Click on the 'Quick Add' on the Hosts(A) section, and just add the @ ip address - have to do three entries. The www will reference to @, so don't need to worry about that one :)


Getting the mongo connection string:

heroku config --long


You'll get some output that includes a line where your mongo connection is:

MONGOHQ_URL         => mongodb://heroku:myPassword@myHost:10013/appname545


You can then take this string, and use it to connect to mongo:

mongo -u heroku -p myPassword --host myHost -port 10013 appname545










We may already have an app and we're on a different machine than the original

  • Install toolbelt - https://toolbelt.herokuapp.com/linux
  • heroku login
  • heroku keys:add [path to keyfile]
  • git remote add heroku git@heroku.com:myAppOnHeroku.git