Setting Up Multiple Domains on Apache with Godaddy
Setting Up Multiple Domains on Apache with Godaddy
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":
4) then i added the .conf file i made with the contents above to apache by running the cmd line command:
5) and then I reloaded apache:
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.
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
Code: Select all
sudo a2ensite wavebuddha.conf
Code: Select all
sudo service apache2 restart
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.