Heal Your Church WebSite

Teaching, rebuking, correcting & training in righteous web design.

Host File Configuration Fun

I realize I’ve been a bit ‘preachy’ the past couple of days, so let me make that up to you by offering something very ‘geeky.’

If you’re like me, you prefer to develop software outside of the production environment. Okay, now to translate that last sentence into English for those of you who are not fluent in ancient geek:

Those of us who program for a living rarely, if ever, perform any major software surgery on live/active website. Instead, we keep a copy of the website, either in a subdirectory on the same web server, or if you are an ‘uber-nerd,’ on a web server you have running in your house (or in the basement of your church) .

Running a web server at home (or in the church basement) for development isn’t all that hard, but setting one up is a topic for a later discussion. Today, I want to talk about how to play some domain games to trick your routers and computers so instead of having to address your site like this:

You can instead address it like this:


Notice, I didn’t enter the URL foobar.com, but just foobar. There a variety reasons for this. First, I really don’t want to spend $8.95 per year to register a test domain for each domain I’m developing. Second, I’m running my Linux/Apache server on an old Pentium II, so excluding the overhead of a DNS daemon gives my tired old machine a bit of a break. Third, unless someone hacks past the Zone-Alarm enhanced firewall on my LinkSys router, there’s a slim-to-none chance that anyone else entering http://foobar/ on their machine is going to see my test site on my intranet.

To do this, it means modifying a file named “hosts” on both my Windows and Linux systems. Here is how mine is configured (almost, the IPs have been changed to protect the innocent). Here is the how the file c:\winnt\system32\drivers\etc\hosts is configured on my Windows 2000 box:     localhost     foobar

Here is how the file /etc/hosts looks on my Linux box (and please note, though I use spaces in this article to delimit the columns, you should use tabs):     foobar     localhost.localdomain     localhost

There are some drawbacks to this approach. First, my Linux configuration assumes I’m working on only one project. If I wanted to work on multiple projects, I would have to configure the Apache system for multiple virtual domains (a.k.a. virtual hosts), each with it’s own IP. In that case, the /etc/hosts file might look like this:     localhost.localdomain     localhost     foobar     blog4god     healed

The file c:\winnt\system32\drivers\etc\hosts would look essentially the same. Which leads me to another drawback, unlike a DNS server that automagically maps these tables for you, you’ll need to keep both hosts files in sync some how – or should I say, rsync (t the reader understand)? Also, if you’re still using Windows 95, 98 or ME, you’ll have to remember that the hosts file is in the c:\windows\host directory, and that Windows XP may be configured so that hosts can be found the directory c:\windows\system32\drivers\etc\.

Another thing you need to remember is that if you haven’t installed some form of web server on your Windows system, then it is more than likely that hosts is actually residing on your system as hosts.sam. This means you need to remove the .sam extension to get things to work.

For you non-BDS Mac users, I believe (and I could be wrong) the hosts file can be found in either the system or the system/preferences filter, and if not, and someone PLEASE correct me if I’m wrong, you simply open up your text editor and create one with the following entries:     A     localhost     A    foobar

I know the above sounds like a lot of work, but honestly, it took me all of 10 seconds to get it done at home. Once done, this allows me to work on a localized copy of MovableType, Drupal or any other tool/toy to work out formats and kinks before they go live. That is, once I go through the ‘heck’ of installing MySQL, php, Perl, and any of other libraries and schtuff required to get a particular app. up and running.

One thing you should note, this approach also works for those of you running an IIS web server at home (on in the church basement) as a development server — and for those of you running a web server on your PC on which you develop — though my preference is always to set it all up an old computer just in case it does get hacked and wacked.

Disclaimer – as always, before you try stuff like this, backup your files, write down your configurations and remember – your mileage may vary (esp. if your router is different than mine).


  1. “If I wanted to work on multiple projects, I would have to configure the Apache system for multiple virtual domains (a.k.a. virtual hosts), each with it’s own IP.”

    I simply use name-based hosting. You route everything to (or a network address would work also) and setup the apache file using:
    NameVirtualhost ip-address

    This is a very handy way to test out websites, especially if you can get php/mysql running.

    Setting up apache is easy, your host will probably be using version 1.3
    There is a version 2.x out, and that’s what I use at home.
    Both are available with a familiar Windows installer at

  2. Top suggestions Dean, but I can think of a much better use for the hosts file