Apache2 VirtualHost subdomains not working?



I have a static public IP and I am hosting my websites on it (Ubuntu Server 12.04). I need to set up a subdomain but It’s not working, even www. is not working. I bought the domain from GoDaddy and I set up the correct NS

I saved the configuration file in /etc/apache2/sites-available under domain.me and then I did a2ensite domain.me and reloaded and restarted apache2, but still no luck.

This is my configuration file

<VirtualHost *:80>
  ServerAdmin webmaster@domain.me
  ServerName  domain.me
  ServerAlias www.domain.me
  DocumentRoot /var/www
  LogLevel warn
  ErrorLog  /var/log/apache2/error.log
  CustomLog /var/log/apache2/access.log combined

<VirtualHost *:80>
  ServerAdmin webmaster@domain.me
  ServerName  me.subdomain.me
  ServerAlias www.me.subdomain.me
  DocumentRoot /var/www/subdomain

curl http://domain.me outputs the index file, curl http://www.domain.me outputs curl: (6) Couldn't resolve host 'www.domain.me' and same for the subdomain


I managed to fix it, and for those of you who is having the same problem, make sure you set up the A records

Answered By – george

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More