How do I create a subdomain and use the same database as in my primary domain?

December 2, 2015 4.9k views
DigitalOcean WordPress Apache Ubuntu

I’m new to apache.

I want to create a client area like using WP database connected to I’ve just configured the DNS for client and wilcard of *.client, but I have no clue what to do after.

What would be the best way to go about it?

1 Answer

The Apache web server uses virtualhost configurations to handle and route content for multiple domain or subdomain names. This guide will assist you in setting this up.

You wont need to do anything special in regards to the database. MySQL does not do virtualhosts and considers all connections to it the same regardless of the DNS name used.

by Justin Ellingwood
The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 14.04 VPS.
  • so if I want a subdomain, I just write instead of in red?

    • That’s correct. As long as a name is pointed to apache in DNS it does not care whether it is a domain or subdomain name and will simply match what you place in the configuration files.

Have another answer? Share your knowledge.