I have a site working on a VM with Debian and Apache. The site is sitename.example.com . Now, I need to add a subdomain like subdomain.sitename.example.com on the same IP.
What have I done until now:
000-default.conf
<VirtualHost 192.167.102.49:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/iamanuser/www/subdomain/public_html
ServerName subdomain.sitename.example.com
ServerAlias subdomain.example.com
</VirtualHost>
apache2.conf
<Directory /home/iamanuser/www/subdomain/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost 192.167.102.49:80>
ServerName www.subdomain.sitename.example.com
DocumentRoot /home/iamanuser/www/subdomain/public_html
</VirtualHost>
etc/hosts
192.167.102.49 sitename.example.com
192.167.102.49 subdomain.sitename.example.com
sitename.example.com works perfect, but everytime I go for subdomain.sitename.example.com the DNS can't be resolved. I'm literally going crazy, please help me. Thanks in advance.
digornslookupon the subdomain? – user3779430 May 06 '15 at 09:53Server: 192.167.101.10 Address: 192.167.101.10#53
** server can't find subdomain.sitename.domain.com: NXDOMAIN
dig doesn't give an answer...
– Mechromancer May 06 '15 at 10:08/etc/hostsis DNS just fine; it is just not a server-based solution and only works locally (so the new subdomain name won't get known to machines that lack this change to/etc/hosts) – umläute May 06 '15 at 11:53nslookupanddigandthe like are tools to query DNS-servers; since you don't use a DNS-server but/etc/hosts, you cannot use these tools; but runningping subdomain.sitename.domain.comon that machine should give you a clue whether things work as expected. – umläute May 06 '15 at 11:56subdomain.example.comavailable to yourself (e.g. for testing), then/etc/hostsis a good solution (but see my answer). But if you want others to be able to access subdomain you need a separate entry on the official DNS server for your domain. – umläute May 06 '15 at 12:06