Add Multiple Domain Name To Digital Ocean Cloud Hosting Ubuntu 20.04

In previous chapter, I had discussed about adding a single domain name to digital ocean cloud hosting (Ubuntu 20.04).  If you have followed that chapter, then adding multiple domain name is just a piece of cake.

Adding Multiple Domain Name

In previous chapter I had discussed how to add a domain name to a droplet. In similar fashion, we can add another domain name to the droplet. (All the chapter list are below this article.)

Once you have added the domain name, then its time to set config file.

In previous tutorial, I had guided how to set a config file.

So for one domain name, inside var/www/html folder, we have uploaded all the files of a website and set the file path in the config file.

To add one more domain, first of all we need to create a directory inside www directory. Remember inside www directory there is html which holds the files of first domain name. You can use any name but use the domain name which you want to add in this www directory.

suppose I want to add examplesite.com as another domain to the same droplet where gyanol.com is hosted. Then I need to create examplesite.com directory inside www directory. Now www directory contains two directory html and examplesite.com.

Its time to create the config file.

The procedure is same with just minor difference.

This time also I am going to create copy of 000-default.conf file.

Using below command, create copy of the 000-default.conf file.

test@tester:~$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/examplesite.com.conf

The above command uses copy (cp) and creates copy of the file 000-default.conf, examplesite.com.conf file. I have used my domain name, you can use any name you want.

Now its time to edit the newly created file gyanol.com.conf

test@tester:~$ sudo nano /etc/apache2/sites-available/examplesite.com.conf

The config file is ready to edit.

<VirtualHost *:80>

ServerAdmin info@examplesite.com

ServerName examplesite.com

DocumentRoot /var/www/examplesite.com

<Directory /var/www/examplesite.com/>

Options -Indexes +FollowSymLinks

AllowOverride All

Require all granted

</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

In the above, red marked text are needed to add in your config file. Select and copy them and paste in your config file. You can set an email for your server admin. Change examplesite.com with your website domain name.

Note: In previous chapter, inside config file, I have used html as root destination. But in this add on domain name, I have used the examplesite.com as root destination.

To save the file and exit, press ctrl+x, then press y and enter.

Now its time to enable this config file so that apache would know about it. Use below command.

test@tester:~$ sudo a2ensite examplesite.com.conf

It will ask to run systemctl apache command to restart the server. Use below command.

test@tester:~$ sudo systemctl restart apache2

Thats it. We have successfully added a another domain name to cloud hosting droplet of Digital ocean.

Now you can upload all the website files to the newly added website directory examplesite.com inside the www directory.

In si’milar fashion add as many website you want in your digital ocean cloud hosting droplet.

Note: There is no restriction in the number of domain name but remember website are highly dependent upon server resources. So if one website performs best then it will impact others. So it is best to go for one droplet for one domain name.

Conclusion

I hope you have understood how to add more than one domain name to a droplet of digital ocean cloud hosting Ubuntu 20.04 server.