I am quite a noob on Ubuntu but I had to install it on a VPS to display two different websites as sub-domains. One of them is a Drupal 8 website, the other one is a Static html website (index.html)
I got both websites on /var/www and I think I configured everything correctly on apache2 because I added the two subdomains to hosts
file to access locally and do some tests and they work fine.
When I type old.myaddress.com
or new.myaddress.com
both of them load locally. However, if I try to access through internet or from another computer, it will only load the Drupal one, always. Why?
Worth to mention that I got a Domain and configured both old.myaddress.com
and new.myaddress.com
subdomains to redirect to the same IP (my VPS server IP). As far as I understand, apache should send the user to the different sites?
These are my .conf files inside etc/apache2/sites-available
:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.myaddress.com
ServerAlias old.myaddress.com
DocumentRoot /var/www/oldwebsite/myaddress.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.myaddress.com
ServerAlias new.myaddress.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
To clarify, I'm asking where the missing configuration is. If loading the websites locally works, it may still be apache? It's my DNS? my ISP? Drupal configuration? I'm quite lost.
hosts
file only works locally, not in a network, so its configuration won't work externally. Asold.myaddress.com
andnew.myaddress.com
point to the same IP, apache serves the first site in available sites. You shoul configure your sites with different IPs, and have a DNS server that point your domains to those IPs. Easier said than done. Take this with a grain of salt. Hope it helps.myadress.com
was merely a placeholder name. I own my domain but I'd rather not make that name public here on SO (security of the server is not yet perfect). The domain and the subdomains are bound to my ip + port. The issue still persists. Note: I don't use My CPanel. I am using Ubuntu Desktop.ServerName
in each toold.myaddress.com
andnew.myaddress.com
. You can remove thenServerAlias
entries.