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 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 184.108.40.206 ; webserver www.test.freebsddiary.org. IN A 220.127.116.11 ; 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 18.104.22.168> DocumentRoot /usr/local/www/data/freebsddiary ServerName test.freebsddiary.org </VirtualHost> <VirtualHost 22.214.171.124> 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
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 http://ww3.freebsddiary.org/. This
is a limitation of the browser, not the website. Sorry.