DNS and Name Servers
Saturday, May 24th, 2008I finally got around to getting my domain names to work with my server.
At first I thought that I should just be able to register my domain name and have it point to my static IP address that I use for my server. But, then I remembered that I we don’t put an IP address for the server, but instead, we put in name servers. Sometimes name servers can be IP addresses, but more often than not, they are domain names themselves.
So, I had to study up a bit on DNS and name servers before I could get it set up correctly. The more I studied the more confused I seemed to get. I really do want to learn more about it, but I will leave the most of it for another day. I figured it out enough to do what I had to do to get it working. That’s all the brain power I had for today
When someone looks for my domain name, that domain name has to be on a name server somewhere. I must tell my registrar where my domain name servers live. Sometimes your domain registrar can and will handle your DNS. This means that your registrar is also your name server. So, basically, your name server is whoever handles your DNS records.
My registrar also handles my DNS records. So, I had to park my domain name at my registrar and then I could go in and manage my own DNS records. Sometimes this costs a little more at your registrar or at your host, but it’s not much more.
I had to add an A record to my DNS to point the domain name to my static IP address.
On my server, I had to add the domain name and static IP address in my /etc/hosts file.
I also had to add the Virtual Hosts information to my apache config files. For my setup, this was a file named 000-default in the /etc/apache2/sites-enabled directory. I added the following:
<virtualhost 123.456.789.012>
ServerName example.com
DocumentRoot /var/www/
<virtualhost>
Once I added this to my 000-default file, I restarted my apache server. That worked!! I can now get to my website using my domain name!
Next I wanted to be able to host more than one website on my server, so I changed the file to this:
NameVirtualHost 123.456.789.012
<virtualhost 123.456.789.012>
ServerName example1.com
DocumentRoot /var/www/website1
</virtualhost>
<virtualhost 123.456.789.012>
ServerName example2.com
DocumentRoot /var/www/website2
</virtualhost>
Again, I restarted my apache server and now I can get to both websites on my server. Oh, by the way, I did change the A record in the DNS for both domain names.
What a rewarding feeling to know that I now have my own websites hosted on my own computer!! And I know a little more about name servers and DNS ![]()

