tobi
By:
tobi

Subdomains?

June 12, 2013 15.4k views
Hey, I'm a newbie and was wondering on how to setup subdomains on Ubuntu 12.04 on DigitalOcean so that the subdomain points to a folder. Thank you
6 Answers
Is it possible to redirect a subdomain that I've created to a specific folder, without touch apache config files? Only using Digital Ocean's DNS admin?
No, that is not possible. You will need to create a virtualhost and configure it to redirect to http://panel.mydomain.com/etc/apps/webmail/.
We have an article on setting up virtualhosts for additional domains/subdomains:

https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts

https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-centos-6
by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one domain off of a single IP address and allows you to run multiple sites off of a single DigitalOcean droplet. This tutorial describes how to set up virtual hosts with Apache.
I am sure there is a guide somewhere on this site that is helpful to a point, but they're vague. No problem there, trying to make them accessible and malleable, but on another page regarding subdomains, Kamal said, "Make sure that DNS is properly setup and restart Apache and you should be good to go."

Now, I understand copying the domain.com file to sub.domain.com in sites-available, then running sudo a2ensite sub.domain.com and then restarting apache.

But as far as the DNS goes...give it to me straight. Do I:
1. Create a new domain record set under DNS in the control panel that is sub.domain.com, with an A record of @ , xx.xx.xx.xx ? Or,
2. In the already existing DNS record for domain.com, simply add another A record of sub.domain.com , xx.xx.xx.xx? Or,
3. Is there another way of doing this?

The site is enabled, but I'm not sure "how to setup the DNS properly".

Thanks very much in advance!
Now, I understand copying the domain.com file to sub.domain.com in sites-available, then running sudo a2ensite sub.domain.com and then restarting apache.
Make sure you edit it and replace all occurrences of domain.com with sub.domain.com as well.

The easiest way would be creating an A record for 'sub' pointing to your droplet's IP on the existing DNS zone for domain.com.
Hello people,

Quick question. Is it possible to redirect a subdomain that I've created to a specific folder, without touch apache config files? Only using Digital Ocean's DNS admin?
Example:

redirect email.mydomain.com ( redirects to http://panel.mydomain.com/etc/apps/webmail/ )
Have another answer? Share your knowledge.