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.

link|improve this question
1  
Your config only shows us one of the 3 sites where are the other's configured and how? – Iain Jul 18 '11 at 20:43
They're also configured under /etc/apache2/sites-available in nearly identical ways. The only thing that changes for each of these is the server name to the domain name(s) it handles, and the physical path. – Robert K Jul 18 '11 at 20:47
The contents of the files and the filenames are important. – Iain Jul 18 '11 at 20:49
Is there anything relevant in your error and access logs ? – Iain Jul 18 '11 at 21:14
@Iain, no nothing. The apache error log shows nothing, and the access logs for the vhosted site only list access to the www.client1.[...] site (no errors for the one without the www.). – Robert K Jul 18 '11 at 21:22
show 4 more comments
feedback

2 Answers

Try it without having a duplicate entry in ServerName and ServerAlias.

For example:

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

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

link|improve this answer
Tried that. I can still access both addresses, but only the one with the www. prefix operates correctly. – Robert K Jul 18 '11 at 21:01
feedback

Some suggestions:

  • Change the <VirtualHost 127.0.0.1:80> for <VirtualHost *:80>
  • Did you place the NameVirtualHost *:80 configuration?
  • Place an index.html file under each DocumentRoot, obviously each with a different message to identify where are you accessing
  • Try accessing from localhost and if it's possible try from another location
link|improve this answer
In FILO order: Localhost access is identical to remote; no need for an index file, all are distinct (but the one gives a "It works" page instead of an Install Wordpress page; transitioning to *:80 from the IP address produces the same result. – Robert K Jul 18 '11 at 21:48
Did you place "NameVirtualHost *:80"? – ghm1014 Jul 18 '11 at 21:51
Yes. It was already there, I just changed the IP to a *. – Robert K Jul 18 '11 at 21:58
I just copied your configuration in my desktop and it works fine. There must be something else, some other config or maybe a browser problem? Cache or something? – ghm1014 Jul 18 '11 at 22:21
Tried with FF, Chrome, and cURL w/the same result. Must be something else in my config files that is doing it. – Robert K Jul 18 '11 at 22:30
show 2 more comments
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.