When im On Shared Hosting im Simply Create a SubDomain From Cpanel But in Digital Ocean How Can We Create Sub Domains?

March 26, 2018 417 views
Deployment Ubuntu

How Can We Create A Subdomain on Digital Ocean Server Because Im Using Shared Hosting Before So Im Creating Subdomains From Directly CPANEL But Now I Migrated My Site (Charter Speed Test) To The Digital Ocean How Can We Create A SubDomain For The Website Please Guide Me Or Give Me Any Tutorial For This.

1 Answer

Hi,

It looks like you are using Cloudflare for your website. There are two parts to making a subdomain work:

  1. Configuring the subdomain to point to your Droplet by adding a DNS record
  2. Configuring your web server to accept connections from the subdomain and serve the right content

Since you're using Cloudflare, Step 1 needs to be done through their control panel. Log in to your account, go to the DNS page, and add an A record with the name as just the subdomain without the domain itself (e.g. sub for sub.mycharterspeedtest.com) and your Droplet's IP address as the value.

For step 2, check out these tutorials:

  1. If you're using Apache: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
  2. If you're using Nginx: https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
by Brennen Bearnes
The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 16.04 server.
Have another answer? Share your knowledge.