Apache2 Virtual Host broken; displayed default index.html on subdomain, but correct content on www.subdomain

apache-2.2virtualhost

I've got a Linode configured as a Ubuntu 10.04.2 web server with Apache 2.2.14.

I have a total of 4 sites, all defined under /etc/apache2/sites-available as virtual hosts. All sites are almost identical clones for configuration. And all sites but my last work successfully.

default:      (www.)exampleadnetwork.com
              (www.)example.com
          reseller.example.com
trouble:   client1.example.com

I keep getting this page when I visit the client1.example.com site:

It works!

This is the default web page for this server.

The web server software is running but no content has been added, yet.

In my ports.conf file I have the NameVirtualHost correctly set to my IP address on port 80.

If I access the "www.sub.example.com" alias the site works! If I access it without the www I see the "It Works" excerpt posted above. Even apache2ctl -S shows that my vhost file parses correctly and is added to the mix.

My vhost configuration file is as follows:

<VirtualHost 127.0.0.1:80>
    ServerAdmin webmaster@example.com
    ServerName  client1.example.com
    ServerAlias client1.example.com www.client1.example.com
    DocumentRoot    /srv/www/client1.example.com/public_html/
    ErrorLog    /srv/www/client1.example.com/logs/error.log
    CustomLog   /srv/www/client1.example.com/logs/access.log combined

    <directory /srv/www/client1.example.com/public_html/>
        Options -Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </directory>
</VirtualHost>

The other sites are variations of:

<VirtualHost 127.0.0.1:80>
    ServerAdmin webmaster@example.com
    ServerName  example.com
    ServerAlias example.com www.example.com
    DocumentRoot    /srv/www/example.com/public_html/
    ErrorLog    /srv/www/example.com/logs/error.log
    CustomLog   /srv/www/example.com/logs/access.log combined
</VirtualHost>

The only site the differs is the other subdomain:

<VirtualHost 127.0.0.1:80>
    ServerAdmin webmaster@example.com
    ServerName  reseller.example.com
    ServerAlias reseller.example.com
    DocumentRoot    /srv/www/reseller.example.com/public_html/
    ErrorLog    /srv/www/reseller.example.com/logs/error.log
    CustomLog   /srv/www/reseller.example.com/logs/access.log combined
</VirtualHost>

Filenames are the FQDN without the www. prefix.

I've followed this advice, but still cannot access subdomain properly.

Best Answer

I experienced the exact same problem and eventually what solved the problem was when I disabled the default site in apache by unlinking it from sites-enabled:

sudo unlink /etc/apache2/sites-enabled/000-default

After doing this, all my sites displayed correctly. I see this question is quite old, but hope this can help someone else out there.

Related Topic