How do I configure a subdomain on my ubuntu?

I have a domain with Godaddy (, I have configured the domain and the nameservers to point at Linode. All that works great.

Now, I want to add a subdomain, I did the following:

  1. Added a CNAME record, with the following info:
    a)Hostname : admin
    b)Aliases to :
    c)TTL : 5 minutes

  2. I went to my server and create a virtual host configuration for the subdomain, based on name <virtualhost *:80="">:
    a)Created a .conf file for the subdomain
    i) ServerName :
    ii)DocumentRoot: Points to the webroot for the subdomain</virtualhost>

  3. I enabled the conf (just like i did for the domain)

  4. All permission for the domain (which works) are the same for the subdomain (in terms of directory and files)

  5. Linode subdomain help page did not help and I had to go to rehab for using it for 5 days.

Please let me know if you need any more info.

2 Replies

There are a number of important details to consider in this deployment regarding both DNS and Apache.

Start Of Authority records

When adding a domain to Linode Manager, it is important to use the most basic form of your domain name. For example, if you own the domain name, you should add it to your Domain Manager as instead of This form is used as the SOA record and serves as the basis for all hostnames configured under this domain.

Configuring this setting incorrectly can lead to unexpected errors. For instance, if you set your SOA record to, then place a record for the hostname admin under that domain, this will create a record for Similarly, a record for www under this SOA record will create the record for the domain name Changing your SOA record from to will resolve this confusion, creating records for the expected domains and

Domain hierarchy

From the perspective of DNS, is considered a different domain name than As a result, and each receive their own set of DNS records which are distinct and separate from each other. It is additionally possible to define separate zones for and by using two separate SOA records as described in the previous section.

Apache ServerName directive

It is definitely possible to set up two separate websites on the same Linode. Since these sites share the same IP address, the ServerName directive becomes necessary so that Apache can use the domain names from incoming HTTP requests to ensure that they go to the correct website.

Personal recommendations

These settings and their interactions can become quite complicated, so I strongly encourage keeping this setup as simple as possible.

  1. Declare your domain name's SOA record to use instead of This will result in hostnames being based directly off of instead of, for predictable and easy-to-follow hostname configurations.
  2. Using as your SOA record, create an A record for the www hostname so that resolves to the IP address of your Linode, then create a CNAME record for admin mapping it to This setup ensures that, even if your Linode's IP address changes for whatever reason, you will only need to change the A record for the www hostname to allow both hostnames to resolve to your Linode's new IP address.
  3. Configure the Apache virtual host block for your administration website with the directive ServerName With an SOA record, a CNAME record for the hostname admin, and an A record for the hostname www, this will cause and to return the same IP address in a DNS lookup. This ServerName directive allows Apache to use the domain name of the request, not just the IP address, to ensure incoming connections go to the correct website even though both websites are served from the same Linode.

Wrapping it all together

DNS is a powerful tool enabling complex and scalable configurations. However, this power and complexity comes with the possibility of misconfiguring your domain's DNS settings. As a result, you may see unexpected results such as having a record but not the expected

I hope this answer helps contextualize our introduction to DNS as well as our DNS Manager documentation, and that it ultimately enables you to successfully deploy your desired configuration. Should you be unclear about any of the information in this answer, please don't hesitate to follow up to this answer with whatever questions you may have.

Thank you very much, this helped very much and I resolved my issue. Cheeerz.

Point #5 in my original post, did not happen.

You rock



Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct