Memorandum on Domains & Web Hosting

A note on the practicalities of putting a website on the internet: understanding domains and web hosting. This material is not required knowledge for the course but should be helpful in real life.

Domains, Domain Name Servers, and IP addresses

Previously, we just assumed that a client can connect to a server and that the client knows where the server is. For example, if you go to www.google.com, we assumed that the client knows where to find that computer. This isn't so simple and direct. There are actually other servers who have the specific job of directing clients to website servers. These are called Domain Name Servers, DNSes, or DNS Servers (yes, that's redundant, but it is common). They fit into the picture like this:

Client-Server Model with DNS
  1. Where is www.thesite.com?
  2. It is at 64.4.11.37
  3. HTTP request to 64.4.11.37
  4. HTTP response to the client's IP address! (made known to server in #3)

Note that a client would (ideally) only have to talk with the DNS before the first time of visiting that website (thesite.com). This introduces a bit of a delay on the first time you visit a site. Just like with a browser cache, your hard drive space is finite, and the browser sets a limit of how much additional information it will keep around; so, after a while, these IP addresses may get flushed out and the client would have to ask a DNS again before visiting a site.

IP addresses

You may have seen IP addresses on TV but not known what they are. IP addresses are simply internet addresses, like street addresses, that (kinda) uniquely identify a computer's place on the internet. Just like real life, some people share an IP address (analogous to apartment buildings) and IP addresses can change hands over time, but especially for professional servers, an IP address represents a fairly permanent address that is unique to that server. IP addresses typically look like four numbers separated by periods. IP addresses in movies and TV shows may look different because they might be obligated by law to use addresses that could not possibly be valid, similar to how they use "555-" in phone numbers.

So the IP address is the actual location of a website server. Could you skip the DNS and just go to an IP address? Yes, you can. This won't always work (see the Lezione 7 discussion on the Host HTTP header*), but it does work a decent number of times, especially for big businesses. For example, www.microsoft.com can also be reached by going to http://64.4.11.37.

* A more in-depth explanation is that many servers nowadays service multiple websites, so even if you know how to reach the server box by going to its IP address, you still have to specify in the HTTP headers which site you want; that's what the Host header is for.

Analogy: 1-800 numbers

Now we have this two-part system of the DNS and the website server, and the domain of "www.thesite.com" isn't exactly the location of the server, it's just a convenient nickname. This may seem confusing. Think of it like this: a large business might have a 1-800 phone number, like 1-800-CALL-BOB. The business gets its phone service and dial tone from a local phone company, and it actually has some other number, like 850-555-0187. People could just call that number, but it is less convenient and not as easy to remember as 1-800-CALL-BOB. So the company pays a separate service who routes 1-800 numbers to regular numbers throughout the country. The routing service doesn't give phone service or dial tone, it just provides convenient-looking phone numbers and it forwards calls.

This is very analogous to .com names. People seemed very slow to adapt to saying ".com" after a name, especially if they have to say three Ws before it. But they have been saying "1-800" for years. So what's the deal? Who knows - people just don't learn so good.

But where is the DNS?

Now, we just assumed that the client knows how to get to the DNS.. But how would that work? Is there a DNS for other DNSes?? Well, not really. Web browsers come hard-coded with the IP addresses of DNS servers.

Setting up a website: domain and hosting companies

Now we know that there are actually two servers in the equation, and these are often handled by different businesses. The DNS side is handled by a domain-name company such as Go Daddy. The website server that we've been talking about is actually more commonly called a "web host", since it is "hosting" your website files. So, if you want to get a site online, you typically have to deal with the domain and the hosting. Go Daddy actually does both, but you might as well shop around. If you look for "web hosting review", you'll find many sites which rate the biggest web hosts.

Dealing with the domain company

You typically deal with the domain company once per year or less; you just buy your domain, set it up real quick, and that's it. Domain prices vary by the suffix: .com, .net, etc. (actually called the "top-level domain" or "TLD"), but they're around $10-$15 per year. You would buy your domain, set up hosting, and then your hosting company would give you some text that you can paste into the domain company's control panel, and that's it; the domain is done. Your hosting company will probably send you a welcome email with intructions of how to set up your domain and point it to the proper place.

What you will actually be copying & pasting are the addresses of small DNSes that the hosting company owns; e.g. ns1.thehosting.com and ns2.thehosting.com. So it turns out that the network of DNSes is actually somewhat hierarchical.

Dealing with the hosting company

You will deal with the hosting company far more often - whenever you want to change your website content. But this is usually pretty easy.

First, you find a host and you go through the short process of buying hosting. You have to choose a hosting product, and for most sites you will want to make, the bottom one or two tiers of hosting service are plenty adequate. These usually range from $4-$8 per month, paid annually or all in advance, with the price difference depending mostly on how long of a contact you buy.

One typical difference in features between those tiers is that one hosting account/relationship in the higher one can be used to service several of your websites. You may get a main folder and then different subfolders of your space can service different sites - e.g. buyknives.com can go to your knives folder, and buytowels.com can go to your towels folder, and all this is transparent to the website user. If you have or aspire to have multiple sites, it is usually a great deal. Another typical difference is that the higher tier gives you unlimited quantities of most metrics, such as hard drive space or transferred data ("bandwidth") per month. Really, unless you want specifically to get one simple site online, you might as well get the better of the two plans. And sometimes this unlimited/multiple-site plan is the lowest tier.

So, once you buy hosting, it may take a day or two for it to get set up, though companies are getting better about this now and it may only take an hour or something. They will give you a welcome email and you can hook up your domain to the hosting, as described above. And then it's time to put your website files online.

Uploading your website; FTP programs

When you transfer the website - or any data - from your hard drive to the internet, it is called uploading (notice how downloading is the opposite). You typically use a certain kind of program to upload your website files: an "FTP program". This is a program that lets you drag files from your hard drive to the server's hard drive and vice versa. For the curious: FTP is File Transfer Protocol (remember HTTP); an FTP program speaks FTP and is analogous to a web browser, which speaks HTTP. You don't need to know anything about the actual protocol to use an FTP program.

There are several free and simple FTP programs. One popular one is FileZilla; you would specifically want FileZilla Client, since you're not going to be setting up an FTP server, just using/connecting to one. You may also want FileZilla Portable, which does not need to be installed and just runs from a folder on your hard drive; you may actually need something like this is you'r working on a computer and don't have administrator privileges (e.g. at your workplace) and thus can't install anything.

Once you get the FTP program open, you'll have to set up a connection to your web hosting server. This is usually with something like File > New Connection. You will only need to set up three things: the "host" (AKA "domain", such as www.yoursite.com), username, and password. (Pro tip: by default, the connection may be of an "Anonymous" type, which doesn't use a username & password; you would have to change it to "Normal".) The hosting company will give you all of these details in its welcome email and/or the help area of its site. Typically, the host is the same as your domain, the username is your username with the hosting company, and the password is the password with your hosting company.

Now that you've set up the connection, you can connect to your web server and transfer files back and forth. This is typically done by dragging files from the left side of the screen to the right side of the screen (will be fairly obvious). You can also drag files from outside the FileZilla screen (e.g. from the Windows folder explorer) into the right side (server side) of the FileZilla screen.

Important: If you have a public_html folder in your web hosting space, your files must go inside there in order to be accessible to your website's users.

So, if you drag whatever.html to your web hosting space (perhaps specifically in public_html), you can now go to www.yoursite.com/whatever.html. And that's it!