Setup Development Domains On OS X
Jake Bechtold | November 22, 2006Back in the day, I did a lot of trial and error designing with the site (when I was working with word). However, I would have to set it up, then upload it to Geocities, then go back and fix. This, however, would have been nice, had I been running OS X.
What I’ve found today, is a way to set up a .dev domain name on your Mac for local developmemt.
1. First, fire up terminal and type in: sudo pico /etc/hosts
This will give you something like this screenshot.
2. Next, you’d want to type in: 127.0.0.1 yourdomain.dev
This basically tells your browser that yourdomain.dev should point to localhost and not try to search for it elsewhere.
3. After typing in that, you’ll want to save that file (Control+X). Keep Terminal open though.
4. Now we need to edit the httpd.conf file for Apache. For me, this is located in /private/etc/httpd/ though your setup could vary. Open up the file in your favorite code editor and do a quick search for “NameVirtualHost”. Make sure it’s not commented out. If it’s comment out, uncomment it out. If it’s not there, then add it. Either way, you should have a line with this: NameVirtualHost 127.0.0.1
5.Below that, we’ll add a VirtualHost rule to tell our yourdomain.dev where to point to.
ServerName yourdomain.dev
DocumentRoot “/Users/UserName/Development/yourdomain”
The DocumentRoot needs to be set to wherever your development folder is for whatever you are working on.
6. Finally, we need to save the file and then restart Apache. Restart Apache within Terminal by typing in something like sudo apachectl graceful (depending on your setup).After restarting Apache, you should be good to go! Fire up your browser of choice and type in your new development domain and you should see your main index file!
Cool, uhu? Of course I won’t be able to try it out until tonight, but it’s a nice, neat trick if you’re someone who works on websites a lot.
How To Setup Development Domains On OS X [The Apple Blog via Digg]
