httpd/dns – adding new domains to your system

httpd/dns – adding new domains to your system

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 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 to resolve to my Apache webserver here at home. 
So I added the following to /etc/namedb/

; please note: this is not the correct IP address.  
; subsitute your own address.          IN A    ; webserver      IN A    ; webserver

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

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:

   DocumentRoot /usr/local/www/data/freebsddiary

   DocumentRoot /usr/local/www/data/freebsddiary

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, 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.

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

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  This
is a limitation of the browser, not the website.  Sorry.

Leave a Comment

Scroll to Top