The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

Things look quiet here. But I've been doing a lot of blogging at dan.langille.org because I prefer WordPress now. Not all my posts there are FreeBSD related. I am in the midst of migrating The FreeBSD Diary over to WordPress (and you can read about that here). Once the migration is completed, I'll move the FreeBSD posts into the new FreeBSD Diary website.

httpd/dns - adding new domains to your system 1 January 1999
Need more help on this topic? Click here
This article has no comments
Show me similar articles
This entry describes how to change an existing webpage on an Apache webserver so that it answers to a new domain.  I'm doing this because ml.org no longer exists.   Hence, the two domains I had under that structure which are now dead.  I have recently registered two new domains.  This section deals with how I made the Apache respond to those names.
What needs to be changed?
Well, I didn't know what needs to be changed so I referred to the notes I kept when I first created the domains.  You might also want to refer to Apache - virtual hosts which describes how to create a virtual host for a website.

I changed two things: my DNS and my Apache.  In the DNS, I added entries for the above webpages.

Changing the DNS
I want the URL freebsddiary.org to resolve to my Apache webserver here at home.  So I added the following to /etc/namedb/named.freebsddiary.org:
; please note: this is not the correct IP address.  
; subsitute your own address.
test.freebsddiary.org.          IN A    11.22.33.44    ; webserver
www.test.freebsddiary.org.      IN A    11.22.33.44    ; webserver

You will note that I added two entries, one of which contains the www prefix.   This allows the user to type either test.freebsddiary.org or Getting local names to resolve :: zone files.  I've also provided the zone file for freebsddiary.org.

I then restarted named to ensure the above changes were activated.  Remember to check /var/log/messages for any errors after the restart.

killall -HUP named
Creating the virtual web servers
When I first created my virtual webservers (see Apache - virtual hosts), I modified /usr/local/etc/apache/httpd.conf.  Here's what I added this time:
<VirtualHost 11.22.33.44>
   DocumentRoot /usr/local/www/data/freebsddiary
   ServerName test.freebsddiary.org
</VirtualHost>

<VirtualHost 11.22.33.44>
   DocumentRoot /usr/local/www/data/freebsddiary
   ServerName www.test.freebsddiary.org
</VirtualHost>

You will notice that I added both URLs with and without the www prefix.  Each entry above corresponds to a DNS entry I made in the previous step (not all of which appeared in the previous section).  If you don't do this, http://ww3.freebsddiary.org/ shows what you will get instead.

I then restarted apache

The virtual web sites
You should now be able to get to each of the following websites.  Each one resides on the same machine.  Each one resolves to the same IP address.

http://test.freebsddiary.org
http://www.test.freebsddiary.org

For example, the above two URLs should give you something like this:

http://www.freebsddiary.org

The FreeBSD Diary - sample virtual website

Not all browsers work with virtual websites
There are only a few browsers which don't support virtual websites.  If yours is one of them, instead of seeing something like the above example, you should see something like http://ww3.freebsddiary.org/.  This is a limitation of the browser, not the website.  Sorry.

Share
Need more help on this topic? Click here
This article has no comments
Show me similar articles