Question

How to create a subdomain in Apache?

  • Posted on December 1, 2013
  • mpsantosAsked by mpsantos

So I just created my Ubuntu server and everything is working fine. I set up the virtual host on my Apache following this tutorial (https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts). My question is: how can I create a subdomain? I want that when you go to subdomain.mydomain.com Apache goes to /var/www/subdomain/public_html (or something like that…).

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Simply follow the steps in the article you cited, but replace <code>example.com</code> with <code>subdomain.example.com</code> (but do <b>not</b> add the <code>ServerAlias</code> directive).

Hello Support,

We don’t have bind server in our server. How can we configure the DNS Server to poin that CNAME.

@dorivalac did you mean private ip or public ip ?