Jun 4, 2012
tom

Creating subdomain results in DNS error

Question

I currently have a site: ‘www.mydomain.com’ and want to create a subdomain called ‘test.mydomain.com’.

I did the following steps below, but am encountering 2 errors:

1) When I go to ‘test.mydomain.com’, I get a DNS error.

2) When I ran ‘sudo /etc/init.d/apache2 reload’, I get the following error msg:

Reloading web server config apache2 apache2: Could not reliably determine the 
server's fully qualified domain name, using X.Y.X.Y for ServerName

Here are the changes I made:

1) /etc/hosts file:

127.0.0.1 localhost localhost.localdomain
X.Y.X.Y www.mydomain.com test.mydomain.com

2) /etc/apache2/sites-available/test.mydomain.com file:

<VirtualHost *:80>
    ServerName test.mydomain.com
    ServerAlias www.test.mydomain.com
    DocumentRoot /var/test/                  
</VirtualHost>
<Directory /var/test/>
        Options Indexes FollowSymLinks MultiViews +Includes
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>
3) /etc/apache2/sites-available/www.mydomain.com file:<VirtualHost *:80>
    ServerAdmin webmaster@localhost    ServerName www.mydomain.com
    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride FileInfo
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride FileInfo
        Order allow,deny
        allow from all
    </Directory>    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>    ErrorLog /var/log/apache2/error.log    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn    CustomLog /var/log/apache2/access.log combined    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory></VirtualHost>

3) I added the following line to the /etc/apache2/sites-available/default file:

ServerName www.mydomain.com

4) Ran the following commands

sudo a2ensite www.mydomain.com
sudo a2ensite test.mydomain.com
sudo /etc/init.d/apache2 reload
Asked by JMan

Answer

DNS error is on the client side. Where did you edit the “/etc/hosts”? You should edit it on the client (the pc where the browser is).

If the problem was with apache, you’d probably get a 404 error or something simmilar, and not a DNS serror.

Answered by mulaz

Related posts:

  1. Can I assign a subdomain to an IP-Address?
  2. Creating Subdomains with Apache
  3. Apache subdomain not working: uses real domain
  4. two different virtual hosts, one page displayed
  5. is there something wrong with this apache vhost?

Leave a comment