I am new to the world of server administration and am trying to learn from the ground up. I am running an Apache2 server on Google Compute Engine and am configuring my domain with Google Domains.
Lets say I have example.io and I want to make sub.example.io
Right now, example.io and sub.example.io both return the content in the directory I've created for sub.example.io.
I'm not sure if the fault is in sub.example.conf, example.conf or my DNS settings.
I've only found people asking about the exact opposite (sub.example.io returns example.io).
example.conf
<VirtualHost *:80>
ServerName example.io
DocumentRoot /var/www/html
<Directory /var/www/html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sub.example.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName sub.example.io
DocumentRoot /var/www/sub/public
<Directory /var/www/sub/public>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/sub-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/sub-access.log combined
</VirtualHost>
And finally my DNS configuration on domains.google.com
Registered hosts:
Host name: sub.example.com
IPV4 Address: servers ip
Custom resource records:
Name: @ Type: A Data: servers ip
Name: sub Type: A Data: servers ip
Name: www Type: CNAME Data: example.io