So I have a website running on a lamp stack on Ubuntu.
I have two vhosts files...
000-default.conf:
<VirtualHost *:80>
ServerName www.example.co.uk
ServerAdmin [email protected]
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/site-a_error.log
CustomLog ${APACHE_LOG_DIR}/site-a_access.log combined
</VirtualHost>
And moodle.example.co.uk.conf:
<VirtualHost *:80>
ServerName moodle.example.co.uk
ServerAdmin [email protected]
DocumentRoot /var/www/moodle.example.co.uk/public_html
ErrorLog ${APACHE_LOG_DIR}/site-b_error.log
CustomLog ${APACHE_LOG_DIR}/site-b_access.log combined
</VirtualHost>
If I go to www.example.co.uk then I see the home page. Exactly as expected.
However if I go to moodle.example.co.uk I still see the homepage not the page stored in the DocumentRoot specified.
If I add a ServerAlias directive to the Moodle conf then it works fine.
Why does the ServerName directive not work?
EDIT: an update. If i disable ALL virtual hosts then my website is still served. this seems like very odd behaviour.
The access is logged in other_vhosts_access.log but I cannot find anything that should lead to this behaviour.
With no vhosts defined should the site just give a connection refused error?