Add Domain Name to Digital Ocean Cloud Hosting

In this article we are going to learn how to set a purchased domain name in Digital Ocean Cloud Hosting.

To host a website in digital ocean cloud hosting, we have to create a droplet first.


Droplet is a reference name, digital ocean has been using to refer to mini-server inside their master server. It provides wide range of droplets. It means droplet with different configuration. The smallest configuration droplet’s rental fee is $5 per month and the configuration is 1GB RAM, 25 GB disk space and 1000 GB transfer. In one single droplet we can add more than one website.

For this tutorial shake, I am going to guide you to install only one domain name.

Pick a desired droplet, install it. Couple of minutes later, your droplet is ready to use.

Add Domain Name

Once droplet is ready. We need to add website. At this point you must be ready with a domain name. There are plenty domain registrar available. Visit one of them and purchase one.

For this tutorial shake, I am going to use website as example.

I had purchased and I want to add to digital ocean cloud hosting.

Inside the main control panel of digital ocean,you would see your droplet.

digital ocean cloud hosting
digital ocean cloud hosting

At the end of the droplet, you would notice three dots. Click on it. A menu list is going to appear. Select the first one ‘Add Domain’. Then following form will appear.

Add Domain

Add your root domain name here. In my case, my root domain name is So I am going to provide in the enter domain box. And then click ‘Add Domain’ button.

After few minutes of processing, your domain name is successfully added to the droplet.

Now, we need to set config file.

Config File

Config file informs apache server about the root destination of a website.

Login to your cloud hosting using putty software.(If you have no idea about it, then follow second chapter from this tutorial series. All the chapter list is present below this article)

Before setting up the configuration file, we need to understand the purpose of this config file. When a user types the url of website, the internet reaches to the ip address of the website, then the apache server takes responsibility to reach the user to the respective file location. The file location in general is /var/www/html. This html folder contains all the files of a website.

Note: we can use any other folder if we want as root destination for a website. For this tutorial,/var/www/html will be the root destination of the website

I must have to upload all the required files of to this folder only. And also I need to inform apache server about this location. We can do this by setting a config file.

Inside ubuntu, there is a file 000-default.conf file. This file is responsible to load the required website. Instead of editing this, we can create copy of this file and set the desired path to the root destination.

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/

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

Now its time to edit the newly created file

test@tester:~$ sudo nano /etc/apache2/sites-available/

The config file is ready to edit.

<VirtualHost *:80>



DocumentRoot /var/www/html

<Directory /var/www/html/>

Options -Indexes +FollowSymLinks

AllowOverride All

Require all granted


ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined


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 with your website domain name.

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

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 domain name to cloud hosting droplet of Digital ocean.

Now upload your website files to this /var/www/html folder.

Note: Do not upload a folder into html folder. Upload files and other directories into the html folder. If you have created website in your local computer system and want to upload the root folder, then first delete the html folder inside the www directory. Then upload your project directory to the www folder and rename the uploaded directory to html. It will work.


I hope you have understood how to add a domain name to the droplet of cloud hosting of digital ocean.