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

While using a cloud server. It always very difficult to setup 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 setup a sub-domain and activate free SSL.

Setup Sub – Domain in Digital Ocean

  1. Login Digital Ocean
  2. Click on the domain – e.g I want to make nexgi.laestrella.store – so I m click on laestrella.store
    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)
    For NON-WWW
    For with WWW

  4. Now your subdomain is pointing to your droplet but – if you will hit/open it. It will open 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 nexgi.laestrella.store under /var/www/
    like I created /var/www/nexgi.laestrella.store
  6. Make a Sample file in this domain with name of index.html with below code – It will help to confirm your sub-domain is pointing right directory.
    <h1>It’s pointing to http://nexgi.laestrella.store</h1>
    
    
  7. Now you have to make a config file in apache at below location
    /etc/apache2/sites-available/nexgi.laestrella.store.conf Please note: this location may differ as per your installation path. Paste following codes & change the bold text as per your domain & pointing directory name.
    <VirtualHost *:80>
    ServerAdmin webmaster@nexgi.laestrella.store
    ServerName nexgi.laestrella.store
    ServerAlias www.nexgi.laestrella.store
    DocumentRoot /var/www/nexgi.laestrella.store
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
  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 nexgi.laestrella.store

    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 http://www.nexgi.laestrella.store/

    Don’t forget to test without WWW
    like in my case http://nexgi.laestrella.store/

Install SSL certificate for free in digital ocean using letsencrypt ubuntu

Rahul Bhardwaj: This guy is familiar with internet. A designer by profession but mostly found poking his nose into many things other than design. He writes about latest technologies, cyber security and fixing gadgets. Got any questions? Connect with him, he is social.

Comments are closed.