Using Terminal to set up a domain for local development

By Geoff Muskett

If you are a web designer it’s more than likely that you need to have more than one website running locally on your computer. No-one wants to edit live, even on a staging site. So this process, in my opinion, is essential.

Apologies to PC folk but this is a Mac based tutorial; I’m running Mountain Lion. This is also aimed at your standard WordPress or other CMS that is based on PHP.

Screencast for Web Deisgners

As a designer, I’m not a fan of Terminal. Give me a slick GUI interface over command line anyday. But setting up locally is not complicated and it doesn’t take long, so you can shut Terminal and fire up your fancy code editor in no time.

First, install Mamp

Fundamentally you need to run Apache, PHP, and MySQL. Mamp does this, it’s free (although there is a paid version), and it’s easy.

If you only run one site, you can just develop in htdocs folder inside Mamp. But it’s way cooler to set up a local domain. Plus as soon as you want to develop another site you’ll need to anyway. So lets jump into it:

Copy and Paste-able

If you can’t be bothered to listen to my ramble on, here’s text instructions that you should be able to copy and paste into Terminal:

1. Open Terminal

Utilities > Terminal

2. Open the file with Vim using global privileges (sudo)

In terminal type, or paste this:

sudo vim /etc/hosts

Type in the main computer password – it won’t show in Termain, but it will work. Hit Enter.

3. Press i to enter Insert mode

4. Add the new local domain

Call it whatever you want, I like to append local. to the real domain. Just makes things a little simpler. Paste this:

5. Press esc to exit Insert mode

6. Save and quit

Type :wq (or to quit without saving :q!)

aaaaand, you’re done.


Leave a Reply

Your email address will not be published.

Join my newsletter

If you’re looking for insights into web design and development, and crafting a successful presence online, then you should join the smart folk on on my newsletter. I discuss my thoughts on an issue relating to the web, then provide and teach effective solutions.