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.
Current DNS Configuration: (each field sepated by “|”) A Record: @ | 22.214.171.124 A Record: forum | 126.96.36.199 A Record: test | 188.8.131.52
I created additional CNAME record as follow to point anything other than the alias specified to www.example.com
CNAME: * | www.example.com.
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 <VirtualHost> 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: /etc/apache2/sites-available/default ServerAdmin webmaster@localhost
DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/>
/etc/apache2/sites-available/test.example.com #NameVirtualHost *:80 #uncomment lead to apache2 startup error <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName test.example.com ServerAlias test.example.com
<Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>
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.
Click below to sign up and get $100 of credit to try our products over 60 days!