Apache2 Virtual Host broken; displayed default index.html on subdomain, but correct content on www.subdomain
Posted
by
Robert K
on Server Fault
See other posts from Server Fault
or by Robert K
Published on 2011-07-18T20:37:14Z
Indexed on
2012/11/14
11:06 UTC
Read the original article
Hit count: 244
virtualhost
|apache2
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 [email protected]
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 [email protected]
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 [email protected]
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.
© Server Fault or respective owner