Question

Any Tutorial to create a subdomain?

I have followed these steps ( https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts ) to create a virtual host, It’s work on simple domains ( example.com ) but on the subdomains ( sub.example.com ) does not work for me. Any help Please!


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.

The procedure is very simple. <br> <br>There are two things to do. <br> <br>first, you need to create a DNS record for your subdomain under your domain like this: <br> <br>Create A record: hostname -->subdomain and IP address is your droplet IP <br> <br>Create CName: Name --> *.subdomain and Hostname is (in this example case) --> subdomain.domain.com. <br> <br>And the second part to create a vhost for your Apache at site-available <br> <br>if you use new version of Apache, then you may need .conf at the end of your site vhost link <br> <br>remember to give your DNS some time about few minutes to 2 hours to propagate so it becomes valid. <br> <br>Good luck!!

what about the DNS ? I handle subdomains by DO DNS system and works fine

Very simple. Just do these: <br> <br>1. In the sites-available directory of Apache, make a copy of yoursite.com file and rename it subdomain.yoursite.com. Replace “subdomain” with the name your want to call the subdomain. <br> <br>2. Edit subdomain.yoursite.com and modify the ServerName line to show the url of the subdomain and the DocumentRoot line to show where the files for the website will be. <br> <br>3. enable the subdomain using a2ensite subdomain.yoursite.com <br> <br>4. Restart Apache. <br> <br>5. try to access the site from a browser. <br> <br>