Cloud Service >> Knowledgebase >> How To >> How To Setup A Sub Domain?
submit query

Cut Hosting Costs! Submit Query Today!

How To Setup A Sub Domain?

A popular chore for developers and website managers is setting up a subdomain. If you want to develop a testing environment, organise information, or grow the size of your online presence, you must know how to establish a subdomain. This article's goal is to provide a thorough rundown of the actions required to set up a subdomain.

1. Understanding Subdomains

Understanding the concept of a subdomain is crucial before beginning the setup procedure. A subdomain functions as a distinct entity inside the parent domain. For example, in “subdomain.example.com,” “s” With subdomains, you can establish specific areas on your website that have exclusive content, functionality, or purposes.

2. Choosing a Subdomain Name

The first step in setting up a subdomain is choosing a suitable name. Take into account these recommendations:

  • Keep it pertinent: Select a subdomain name that accurately captures the intent or subject matter of the area it covers.

  • Keep it brief: Memorable, short subdomain names are simpler to type and recall.

  • Steer clear of special characters: Use hyphens and alphanumeric characters only; special characters could break compatibility.

  • Think about SEO: If appropriate, use pertinent keywords in the name of your subdomain to increase its exposure in search results.

3. Configuring DNS Records

You must set up DNS (Domain Name System) records that refer to the correct server after selecting a subdomain name. Take these actions:

  • Use the management panel offered by your DNS hosting company or domain registrar.

  • Find the domain settings or DNS control area.

  • Your subdomain needs a new DNS record, so make one. Usually, this entails choosing the record type (such as an A record or CNAME record) and inputting the hostname or IP address that corresponds to the subdomain name.

See the documentation or support materials from your hosting provider if you're not sure which kind of DNS record to use.

4. Setting Up Web Server Configuration

You must setup the DNS records and then the web server so that it can identify the subdomain and provide content appropriately. Depending on the web server software you're using (Apache, Nginx, etc.), the precise procedures may change. This is a broad overview:

Apache Web Server:

  • Change the configuration file for Apache, which is often found at /etc/apache2/sites-available/.

  • For your subdomain, add a new VirtualHost directive with the document root and subdomain name specified.

  • To make the setting take effect, save the modifications and restart the Apache service (sudo service apache2 restart).

Nginx Server:

  • For your subdomain, create a new server block configuration file (subdomain.example.com.conf) in the /etc/nginx/sites-available/ directory.

  • Define the server block parameters, including the document root, server name (subdomain), and additional instructions.

  • To establish a symbolic link and turn on the new settings, use sudo ln -s.

  • To check for syntax errors in the Nginx configuration, use sudo nginx -t. To restart the Nginx service, use sudo systemctl reload nginx.

5. Verifying Subdomain Setup

It's crucial to confirm that the subdomain setup is operating properly after finishing the setting stages. Here are a few ways to confirm:

  • Ping Test: To make that the subdomain resolves to the right IP address, use the ping command. Enter ping subdomain.example.com in the terminal or command prompt window. Responses from the right IP address ought to appear for you.

  • Browser Test: Open a web browser and type the subdomain URL (http://subdomain.example.com, for example) to make sure the intended webpage loads.

  • DNS Transmission: Remember that it could take some time for DNS updates to spread around the world. To confirm that the DNS entries for your subdomain have spread to the relevant DNS servers, use online DNS lookup tools.

Conclusion

Configuring DNS records and web server settings to establish a separate area of your website is the process of setting up a subdomain. You may efficiently set up a subdomain and take advantage of its advantages for content organisation, test environment creation, and online presence expansion by following the instructions provided in this article. To guarantee seamless operation, don't forget to select an appropriate subdomain name, precisely configure DNS records, set up web server settings, and double-check the setup.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!