Friday, January 9, 2009

Field Guide to Setting Up Your Home Webserver

Well, it's taken a while, but I finally have up and serving pages from my server at home. This has been much more difficult than it should have been and the saga features four different operating systems, two DNS servers, multiple calls to my cable Internet provider, and more than a few headaches. I think that there is very little thorough documentation out there about setting up a website from your house, so let me take a stab at it.

First the background:

I have a Dell SC430, an old piece of crap small business server that is pretty stripped down. I had OpenSUSE 10.2 installed on it initially, which at first was fine - it seemed to agree with my system in a pretty plug-and-play fashion. I was pleased enough with the UI, and it performed great considering it really wasn't a very high-horsepower setup, but then bad stuff happened, and I moved onto Ubuntu 8.04. Now, I have already described my admiration for Ubuntu 8.0.4. It seems to come with most everything that you need on your server. My biggest problem with Ubuntu wasn't really a problem with Ubuntu I guess - the resolution on my 22-in monitor wouldn't be recognized, no matter what I tried. Apparently, this has to do with the bobo graphics card (Radeon ES1000) that is delivered with the Dell SC430. Anyway, long story short, the screen was awful to work with, and I had heard great things about OpenSUSE 11.0.

I gave it a shot. The screen resolution was recognized right away. That was good - it was very fast, and had a great look to it. The rub was, every time I tried to setup the network, I would lose my network connection altogether. Even when I hit finish after making no changes, it would hose my connection completely, and I would have to uninstall and reinstall my network driver. Not that great. The package manager is much better on SUSE 11 though. So, I had an epiphany. My loyal readers will remember that RCN screwed me out of running a media center PC at home, because they are bad, bad corporate citizens. I thought, why don't I make this server just a server that I only connect to using ssh, and use the idle media center as my computer at my desk. Eureka! I downloaded Ubuntu Server Edition 8.10, since Ubuntu did what I wanted it to. Within mere minutes, I had a server installation loaded up, no problem.

Now that I have woven this tale of woe, it's time to actually talk about what I meant to talk about: how to actually set yourself up to have a domain name and a webserver.

Step 1) Get your domain name. I use It's a terrible website, but it is pretty cheap and simple enough.

Step 2) Get a static IP - this is more or less expensive based on whether or not you have an evil ISP. Despite RCN's lame decision to force cable boxes on the masses, they have REALLY cheap business internet and static IP costs. I pity the fool who uses Verizon DSL. It was MUCH more expensive through them.

Step 3) Set up your router - the steps I am describing are for a netgear wireless router. I assume it's pretty much the same no matter what router you have as long as it's not a complete piece of junk, and was built recently:

a) Set a static IP address for your server - this can be achieved by mapping an IP address to your server's mac address. This means that every time your server receives an IP address, it can be one of your choosing.
b) Setup port forwarding - now that you have it established that your server is listening on port, you can setup port forwarding. The obvious port would be 80, the default http port. You can point 80 over so that all http requests to your ip address are routed to the web server on the server.

Step 4) Set up your entry in a Domain Name Server (DNS). You need to tell the Internet that your domain name is associated to your statically assigned IP address. This is accomplished by adding an entry to a DNS somewhere. There are a bunch that you have have to pay for, but thankfully, there are a few that are free, and seem to work pretty well. I personally used It's simple to say "associate this name with this IP address". Then go back to your hosting account, and set the nameservers on the domain name to point to the nameservers you just setup. Now the web knows that points to This takes a while to propagate across the web, so give it time. Once it gets to your ISP though, you will be able to type your domain name in and have it resolve to your IP.

This is the setup that takes place outside of your server. Now you can move on to the good bits, setting up your content, your webserver, and any operating-system level configuration required to serve pages to the internet.

Step 1) If you don't have it already, get apache. There are about a billion tutorials on installing apache, so I won't bother you with the details there. Once you have it installed and running, you should be able to type http://localhost and see the stock apache page that says you have it installed. Now you are ready to do your thing.

Step 2) Decide how you want to host your content. Do you want to host just one directory worth of stuff, or do you want to have a slightly more complicated setup. I want to use for more than just one directory. I would like to have a homepage that can link to as many things as can think of to host. Here's how I did that:

a) set up my web root at /my/path - all you have to do is have an index.html, or index.php - whatever start page is defined in your apache configuration - just search for 'DirectoryIndex'. Add your homepage there.

b) setup as many directories of other content that you want. These directories will be referred to by subdirectories. is an example of this. These will host the content of your 'applications'.

c) now setup your virtual host. There are quite a few examples on how to do this on the web. The most clear documentation I have found is here. The idea is that you want to tell apache that if it gets a request with this path and this URL, on this port, here is what you want it to do. In this case, I may want to host multiple sites, but currently just So I define one virtual host, saying if you get this request, here's the pages you should serve:

  1. <Directory /photo/app/directory>

  2. Options FollowSymLinks

  3. AllowOverride Limit Options FileInfo

  4. </Directory>

  5. <VirtualHost>

  6. DocumentRoot /my/content/path

  7. ServerName

  8. Alias /photos "/photo/app/directory"

  9. <directory "/photo/app/directory">

  10. Options Indexes

  11. AllowOverride None

  12. Order allow,deny

  13. Allow from all

  14. </directory>

  15. </VirtualHost>

Step 3) Setup your /etc/host file. This file will tell your machine that when things get requested on certain IPs, do this: localhost ubuntu-server

The IP address for your site comes from the settings above (whatever IP address you assigned to your server). Restart apache for good measure after updating this file.

So that's it - now restart apache, and if your directories are in the right place, you should be all set to start serving your pages to the world. Hope this helps, and feel free to chime in with some pointers or corrections.
blog comments powered by Disqus