Thank you for help in advance.
I recently registered a domain name and wish to create multiple subdomains, which are to be hosted on a droplet under a single IP address using virtual hosts. The following are my desired configuration.
Domain name: example.com, subdomain 1: test, subdomain 2: forum.
Alias "test.example.com" point to subdomain 1 and "forum.example.com" point to subdomain 2.
Current DNS Configuration: (each field sepated by "|")
A Record: @ | 188.8.131.52
A Record: forum | 184.108.40.206
A Record: test | 220.127.116.11
CNAME: * | @
CNAME: *.forum | forum.example.com.
CNAME: *test | test.example.com.
I created additional CNAME record as follow to point anything other than the alias specified to www.example.com
CNAME: * | www.example.com.
The CNAME entry worked and it pointed example.com and fdasas.example.com to www.example.com, however, I got error messages on the control panel page after adding the above entry.
My other questions are regarding to virtual host configuration:
Do I need to create a separate virtual host configuration file for each virtual host under /etc/apache2/sites-available or I simply add a block on the existing default configuration?
Do each virtual host need to listen to a different port for them to work?
My config are as follow:
#NameVirtualHost *:80 #uncomment lead to apache2 startup error
Options Indexes FollowSymLinks MultiViews
allow from all
I followed tutorial on these setup, but I am unsure if I need to have 1 config file for each virtual host or 1 config file for multiple virtual host.
I apologise if the question seem obscure, please let me know so I can explain better. Thank you for your help!
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.