Wednesday, May 4, 2011

How To Set up a DNS Alias - Serving Multiple Domains from One Web Machine

It's easy to set up DNS aliases with the Apache Web server. What this means is that if you have one Web domain or 100 you can set them all up to point to different directories on your Web server and host them all yourself.
Difficulty: Hard
Time Required: 10 minutes
Here's How:
  1. Create the directory on your Apache Web server.
    Be sure to put the directory within your Web server directories, and not in any location on your machine. For example, most apache server Web files are located in the htdocs folder. So create a sub-folder there to host your domain files. It's a good idea to put an index.html file in the directory so you can test later.
  2. In version 1 of Apache, edit the apache.conf file and find the vhosts (virtual hosts) section.
    In version 2 of Apache, edit the vhosts.conf file.
    These are usually located in a configuration directory on your Web server, not in the htdocs area.
  3. Edit the vhosts section to add a new virtual host:
    <VirtualHost IP_ADDRESS>
    ServerName DOMAIN NAME
    DocumentRoot FULL_PATH_TO_DIRECTORY
    </VirtualHost>
  4. Restart Apache.
  5. Edit your named.conf
  6. Add an entry for the domain:
    zone "DOMAIN" IN {
    type master;
    file "LOCATION_OF_DB_FILE";
    allow-transfer { IP_ADDRESS; };
    };
  7. Create the db file for the domain
    The simplest way is to copy other db files and add your new domain.
  8. Reload your DNS
  9. Test your domain in your Web browser.
    It can take several hours for your DNS to propagate, but as long as you're pointing to your local DNS you should be able to test right away.
What You Need:
  • Apache Web Server
  • Named DNS
  • Access to conf files
 

No comments:

Post a Comment

Confused? Feel free to ask

Your feedback is always appreciated. I will try to reply to your queries as soon as time allows.

Note:
Please do not spam Spam comments will be deleted immediately upon my review.