Index:
Non-OSXS Preliminaries:Of course, to get this whole show off the ground, you have to have a domain name registered, at least one static IP address, and have your machine registered as a name server with Network Solutions. To get yourself registered as a domain name server, head over to Create a Name Server Host. It's quick and easy, and more importantly, free. You have to pick a name for your name server, and you may want to name it something like "ns.yourdomain.com" or somesuch. They walk you through the procedure, and I believe you have to bounce a few emails back to them and so forth. Can be done while you're setting up your name server. Now, you then have to tell Network Solutions that your web domain (and I'm assuming that you have one, or that someone out there who is planning on using your name server has one) has your machine listed as the primary name server. So head over to make any changes to your current web domain and get your name server info updated. But what about the *secondary* name server? Well, if you only have one machine that going to be doing the name serving, you'll have to find someone else's machine (which runs a name server) to agree to be the secondary name server for your web domain. That means supplying them with info about your domain and probably agreeing to pay them some small monthly fee to handle the traffic should your site go down for whatever reason. Often, your ISP may agree to slightly hike up your monthly bill in exchange for being the secondary name server. Or, you may have a friend who has a name server - and this is probably the most cost-effective route - and you can each agree to be each other's secondary name server. (You may want to make sure you each get about the same level of net traffic, so that one of you doesn't get unduly overloaded if the other goes down.) If you have more static IP address and another machine that can function as a secondary name server, you may want to register that as a name server and set it up as well. Of course, if both machines go down, then all outside requests for your domain name will come up with no info at all, so make a guess as to what's best for your situation. (I have my ISP secondarily name serve me.)
Setting up the "named" files:There are five files which you need to create in the /etc directory: (Actually, you can put these files other places, and you could even keep them in /local/ directories for people running multiple named processes, but I'm just going to set it up the way it is on my machine, assuming that you, the admin, are in charge of all this.) Their set up is a bit odd, but formulaic at least. I'm going to just write them out in text form, so that you can simply copy them and paste them into a text editor, but I'm going to make up a demo web host and ip#. So, let's say the web domain is yourdomain.com at IP# one.two.three.four, and let's say we registered our name server as ns.yourdomain.com. Once you get all these files in place, you should be all ready to go with one simple command: named & (the "&" runs the process in the background, in case you haven't run across that before). You can also add this to your boot file, if you have need to reboot your machine ever. (I have memories of having to reboot, but they're getting hazy now... ;-) If there's something wrong with what I'm saying below, please let me know. (all the files will be in the /etc directory, which, if you're root, is an alias to /private/etc - a good directory to get familiar with if you aren't already)
This is much easier, just copy it and plug in your specifics. You also need those extra periods at the end of the server and domain names. SOA designates your name server as the "Source Of Authority," NS is your name server's official name, and PTR (stands for?) allows name lookups given the ip number. For more about this stuff, check out The DNS Database Files. From what I hear, if other machines are connected and using your name server directly, change the serial number each time you restart named. Solo name servers, don't worry about it.
Nothing fancy going on here. The last two lines are the fun part. This is where you can start dishing out the subdomains. If you're running everything off a single IP number, then just keep repeating that IP number for each subdomain. The above coding hooks up www.yourdomain.com and fun.yourdomain.com. Add all the subdomains you want, but remember to tell apache.config what you did (virtual hosting-wise), and also that you have to restart both named and Apache each time you add a subdomain.
Here we have a file which gives a way for an IP number to get mapped to the correct domain and subdomain. If you don't have a subdomain, then don't add that last line in there. (Note that "four" in the above is the last part of your static IP number. If you had several seperate machines with a unique final IP digit each, you'd match the final digit to each subdomain which they handle.)
This is the simplest of the files. It just contains two bit of info: what domains you have pointing to your name server, and what nameserver's your computer is hooked up to. I'm not positive if you have to include your ISP's name server's in here, but every example I've seen does so, and who am I to argue with success? (Of course, as always, if you know better, let me know.)
Working it out with Apache:Getting Apache to go along with all this is not too difficult, but I'll just lay out the basics. If you want to know the ins and outs of this, be sure to go through the great Apache site. You'll have to add a few lines to the apache.conf file, usually located in the < VirtualHost one.two.three.four>
ServerName www.yourdomain.com
DocumentRoot /the_directory_for_this_address/
CustomLog /Local/Library/WebServer/Logs/www.log combined
< /VirtualHost>
You can add as many of these as you like, and point them all to their own seperate directory or the same ones. I create a seperate log for each subdomain, but you may prefer one big log for all of them by pointing them all to the same logging file. You can keep your web serving files on any of your drives, even the HFS+ drives (for which I've noticed no noticeable speed hit).
Adding new Domains / Sub-domains:Ok, just some quick end notes here, as I'm getting tired... The files you need to update when you are adding a whole new domain are:
and create a named.newdomain.hosts file and the files you need to update when you add on a new subdomain to any already hooked up domain:
When you update those, you need to start the named process and restart it again (named &), and also stop and restart the Apache server (apachectl stop, then apachectl start). |