Manage hostnames on Mac OSX with Ghost

As a Web Developer , one of the things that We always need mess with will be the domain name and ip, the host file in our system ( be it PC/MAC/Linux) will be direct which domain forward to which ip , this is useful for a few scenario

  1. When you do local development, you want your dev.local pointing to one of the development folder, you need to create a virtual domain and make it point to your own system and setup the Apache virtual host pointing to the correct folder.
  2. You just change the domain name DNS  , the propagation is still on the way , you can change it on your host file to instruct the system to send any request to this domain to the new ip, this allow you to continue setup the new site while waiting for the propagation to complete.

On a Mac , we just use the root login and edit the host file, it sound ok if you just need to do it once in a while, but if you often need to make lots of changes, it seem like a bit tedious. So this is one script that I learn from setup LAMP on Snow Leopard , using Ghost to manage the hostname.

You can install this script/utility by just one line command on your terminal app.

[box type=”note”]sudo gem install ghost[/box]

the command line for this script is quite simple and straightforward.

  • ghost add
  • ghost delete <hostname>
  • ghost list

using this script you can set up multiple virtual hostname fast and easy to change, this should help to speed your development.

You may also like...