Hi there, this is probably out of order, but I want to blog a bit on how to set up a sub domain on your windows/apache box.
I have control over my DNS
What this means is that I can use A records and CNAME records to point my domains to my local box. If you are unfamiliar with DNS, this is probably over your head, but all you have to do is change the A record for your primary name (in my case ph-balanced.com) and point it to the ip address where I am serving my pages from. I have my router passing port 80 to my web server, so only that port is serving web.
So It goes Name server - DNS - Router - Local machine.
Pretty straight forward, and a little firewall goes a long way! Everything is as locked down as my router will make it.
I had to edit my 'hosts' file
I have a static ip to my web server, but windows didn't know what to do, so I had to add entries to my C:\WINDOWS\system32\drivers\etc\hosts file. To be honest, I'm not quite sure if this is a good idea, but it's what had to happen to make my computer understand my domain names.
xxx.xxx.xxx.xxx ph-balanced.com
xxx.xxx.xxx.xxx drupal5.ph-balanced.com
and I had to restart.
So, to get sub domains to forward to the proper pages, I have to do a few things, but not a lot.
- Make a CNAME record for your sub domain in your DNS. This is the key.
Name drupal5.ph-balanced.com 
Class IN 
Type CNAME 
Status Active 
Value ph-balanced.com It may take a while for this to propagate, but it will happen.
- Add in a virtual host in Apache's .conf file (you may already have some added in)
NameVirtualHost ph-balanced.com
<VirtualHost ph-balanced.com>
ServerName ph-balanced.com
DocumentRoot "######/htdocs/"
</VirtualHost>NameVirtualHost drupal5.ph-balanced.com
<VirtualHost drupal5.ph-balanced.com>
ServerName drupal5.ph-balanced.com
DocumentRoot "######/htdocs/drupal5.ph-balanced.com/"
</VirtualHost>I added these to the end of the file. Notice, I named the sub domain's file as the sub domain's name. I read in a post somewhere this was a good idea. Restart Apache!
That's it - you should have a new subdimain in no time. Let me know what does not make sense.

Comments
Very good post, thanks a lot.
Very good post, thanks a lot.
Post new comment