05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Domain Name Tricks<br />

Were you so inclined, you could set up a DNS server . . . but why? Chances are your registrar has<br />

a name server, so providing you have a static outside IP address, you can simply have them point<br />

to it and start welcoming visitors to your self-hosted web site.<br />

However, not everyone has the need to spend the money on a static IP address. Especially<br />

when you consider that the cost of getting one is greater than the cost of professional web hosting.<br />

If you’re setting up a web host just because it’s fun, because you want to save money, or<br />

because you’re doing local development, paying for a static IP address is overkill.<br />

Custom Domains Without DNS<br />

You can actually override DNS at a local level. <strong>Mac</strong> <strong>OS</strong> X maintains a list of known hosts in a<br />

file called /private/etc/hosts. Editing this file will let you map web addresses to IP addresses.<br />

Why would you do this?<br />

First, looking at IP addresses all day is boring. That’s why DNS was invented, after all. It’s<br />

much more fun to give your local network machines fun names at imaginary top-level domains.<br />

Then you can surf over to http://mike.is.awesome.<br />

Second, if you are developing web pages locally, you might run into a problem with absolute<br />

paths. That is to say, if you have a link pointing to www.mydomain.com/somefile.php, your browser<br />

will want to go to the remote version, rather than the local version you’re developing.<br />

The hosts file is the first place your machine looks when it tries to resolve a domain. Rerouting<br />

calls to mydomain.com or www.mydomain.com to your local machine is easy. Just open /private/<br />

etc/hosts in your favorite text editor, and then add the following line:<br />

127.0.0.1 mydomain.com www.mydomain.com<br />

Just remember to edit the hosts file back to normal before trying to surf the Web, or strange<br />

things might happen. For more information on the hosts file, invoke man hosts in Terminal.<br />

CAUTION It’s OK to add things to the hosts file, but don’t edit any of the existing entries. The<br />

system has that stuff there for a reason.<br />

Dynamic DNS<br />

CHAPTER 22 LEOPARD AS A WEB SERVER 397<br />

What if you want to serve a personal web site from your home, but you don’t want to pay for a<br />

static IP address? You could just update your registration every time your address changes, but<br />

given the time it takes for DNS changes to propagate, you could be looking at a lot of downtime.<br />

Even for a home project, that just looks sloppy.<br />

A better option is to use a dynamic DNS service. There are many cheap-to-free services,<br />

such as No-IP (www.no-ip.com/) and FreeDNS (http://freedns.afraid.org/), that will let you point<br />

a domain name to your dynamic IP address. Unlike a standard name server, dynamic DNS services<br />

keep a very short refresh time on their name servers, so changes propagate quickly.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!