Setting Up Multiple Domains on Apache with Godaddy

all about tech.
Post Reply
george
Site Admin
Posts: 16
Joined: Thu Aug 01, 2019 3:16 am
Setting Up Multiple Domains on Apache with Godaddy

Post by george » Sun Sep 13, 2020 10:38 pm

In this guide we will discuss how to setup multiple domains and configure them with apache on Ubuntu.

I have a domain (www.techmasterdesign.com) that forwards to the root directory of my webserver (/var/www) with dynamic DNS. I also have another domain (wavebuddha.com which i wanted to forward to /var/www/wavebuddha), but I wanted wavebuddha.com to show up in the URL bar, not techmasterdesign.com/wavebuddha.

Here’s what I did:

1) on godaddy (in the configuration for wavebuddha.com), I created an A record which points to my IP address (dynamic unfortunately, but I can live with changing it OR use this script to update it automatically https://github.com/CarlEdman/godaddy-ddns)

2) also create a CNAME www record with techmasterdesign.com

3) on the apache side, I created a .conf file in /etc/apache2/sites-available called "wavebuddha.conf":

Code: Select all

<VirtualHost *:80>
ServerName wavebuddha.com 
ServerAlias www.wavebuddha.com 
ServerAdmin webmaster@localhost
DocumentRoot /var/www/wavebuddha
ErrorLog {APACHE_LOG_DIR}/error.log CustomLog {APACHE_LOG_DIR}/access.log combined
4) then i added the .conf file i made with the contents above to apache by running the cmd line command:

Code: Select all

sudo a2ensite wavebuddha.conf
5) and then I reloaded apache:

Code: Select all

sudo service apache2 restart
Understanding things
Even though we are forwarding a domain that lives in a subfolder (wavebuddha.com) to techmasterdesign.com, which you would think forwards that URL to the root webdirectory (/var/www), the key line is "DocumentRoot /var/www/wavebuddha" in etc/apache2/sites-available with the servername and serveralias set to wavebuddha.com. Apache can tell when you send someone to techmasterdesign.com where the request is coming from and route them to the correct folder. It is kind of confusing but it works because of the .conf file.


Post Reply