DNS and Name Servers

May 24th, 2008

I 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 :)

Kitty Update!

May 24th, 2008

Our new kittens are growing like little weeds! And getting cuter by the day. I think they’ve tripled in size.

Kitten

Our New Baby Kittens

May 17th, 2008

Our cat had kittens in our garage last Monday. They are SO cute! There were five of them all together, but one of them died on Wednesday. I read that their little eyes will open between 5 and 14 days, so they could start opening at any time now. I hope to keep you posted as to their growth. And I will take lots of pictures. :)
Baby Kittens

Making My Static IP Work With My Web Server

May 14th, 2008

I finally got my static IP address from my ISP, hooked up the modem, router, and computers but still I couldn’t access my website from the outside world. When I typed in the static IP address, it would just sit there and finally time out.

I tried it with the Ethernet cable coming from the modem to the router and then to my linux computer - that didn’t work. So, I tried it with my ethernet cable coming from the modem straight to the linux computer and then another ethernet cable from the modem to the router for all the other computers in the house. That didn’t work either. So, now what?

I talked to my friend, Dean, at work, who is the smartest person I know when it comes to networking. He even drew me pictures. :) But, the one thing he told me that did the trick was how to set up my network interfaces file on the linux box that will let it know it’s static IP address. I’m sure I would have found that in a book or online if I’d looked long and hard enough, but it’s always nice to have a ‘Dean’ to save you from all the trouble. :)

So, I added my static IP address, gateway and subnet mask that was given to me by my ISP to the /etc/network/interfaces file and then ran ‘/etc/init.d/networking restart’ just like Dean told me. And, guess what? It works like a charm! I didn’t even have to get an extra networking card like Dean said I might. And I didn’t have to get another static IP address like Dean also said I might need. I just had to add the right stuff to the right file. :)

I installed SSH so that I can shell in from anywhere and now everything seems to be running well and I can now access my Linux box from anywhere with internet access.

Thanks Dean!

Today’s Tip: php’s array_merge() doesn’t work well with an empty array

May 6th, 2008

I spent several hours last night trying to figure out why my code wasn’t working. I had an array of tags that I wanted to add to my database. But, I only wanted to add the tags if they hadn’t already been added. The API that I was using only had a method to return me an array of the tags that were already on the database. So, I decided to get that array and then merge the two arrays, take out the duplicates with array_unique() and then find the difference (array_diff) between those unique tags and my new tags. The different tags would need to be added to the database.

What I didn’t know was that an empty database, producing an empty array would not work with array_merge(). Instead of just duplicating my new tag array (which is what I thought it would do), it gave a warning and didn’t return anything. So, my tags were never being added to the database.

I spent several hours tracking down that bug (mostly because it was in a SOAP call which ran very slowly for each test). Hopefully, this will help someone else not make the same mistake!

Happy Programming!

Cindy :)