httpd/dns – adding new domains to your systemThis 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 DNSI 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 126.96.36.199 ; webserver www.test.freebsddiary.org. IN A 188.8.131.52 ; 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 serversWhen 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 184.108.40.206> DocumentRoot /usr/local/www/data/freebsddiary ServerName test.freebsddiary.org </VirtualHost> <VirtualHost 220.127.116.11> 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 sitesYou 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