Development, Technology

How to setup Sub-domain in digital Ocean and Activate SSL

Written by Rahul Bhardwaj
Posted on - 3 min read

While using a cloud server, It always very difficult to set up a domain or sub-domain in the digital ocean or AWS & activate SSL. In given few steps I will explain to you how easily you can set up a sub-domain and activate free SSL.

Setup Sub – Domain in Digital Ocean

  1. Login to Digital Ocean
  2. Click on the domain – e.g I want to make – so I m click on
    As marked in red.

  3. Then Add two records as given screenshot
    First nexgi second  www.nexgi (only write bold text) and point to your droplet. (see below)
  4. Now your subdomain is pointing to your droplet but – if you will hit/open it. It will open the default or main domain. So now you have to tell which folder will be pointed when someone hit this sub-domain using a virtual host.
  5. Access your terminal/or GUI method & create a folder where you want to point this subdomain like I created under /var/www/
    like I created /var/www/
  6. Make a Sample file in this domain with the name of index.html with below code – It will help to confirm your sub-domain is pointing right directory.
    <h1>It’s pointing to</h1>
  7. Now you have to make a config file in apache at below location
    /etc/apache2/sites-available/ Please note: this location may differ as per your installation path. Paste the following codes & change the bold text as per your domain & pointing directory name.
    <VirtualHost *:80>
    DocumentRoot /var/www/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
  8. Now, this site is available but not enabled or activated to work.
    To enable it – you need to press a small command from terminal & change the bold sub-domain as per yours.
    sudo a2ensite

    Then reload your server configuration – by hitting

    service apache2 reload
  9. Now you have enabled successfully – Just you need to reload your server configuration. Navigate your sub – domain – like in my case –
    With WWW

    Don’t forget to test without WWW
    like in my case

Install SSL certificate for free in digital ocean using letsencrypt ubuntu