I've got a Ubuntu 10.04 LTS machine with a classical LAMP installed. I've created two sites:
A public site, on www.mysite.com
A "private" site that for the moment is open, on private.mysite.com
I've created two different config files for them,
/etc/apache/sites-available/mysite
/etc/apache/sites-available/private-mysite
With the default Apache virtualhost configs. No wildcards, the ServerName are www.mysite.com and private.mysite.com respectively, and I haven't used wildcards.
And of course there symlinks to those on /sites-enabled. Each of the sites has its own directory,
/var/www/mysite
/var/www/private-mysite
The public site is a WordPress blog. The private site is a webapp with several php files.
Everything should fine, and I've checked everything several times, but something weird happens. When I visit private.mysite.com the private part goes well.
But when I visit www.mysite.com, the server goes directly to private.mysite.com.
Apache logs show that those requests to www.mysite.com aren't even logged on
/var/www/mysite/logs/access.log (or error.log)
They go instead to
/var/www/private-mysite/logs/access.log
So EVERY request goes to the subdomain. Any ideas to correct this behaviour?
************** Update *******************
More info:
ls -l /etc/apache2/sites-available/
-rw-r--r-- 1 root root 859 2011-05-27 13:33 private-mysite
-rw-r--r-- 1 root root 948 2010-11-18 22:16 default
-rw-r--r-- 1 root root 7467 2010-11-18 22:16 default-ssl
-rw-r--r-- 1 root root 264 2011-05-27 14:22 mysite
/etc/apache2/sites-available/private-mysite contents:
<VirtualHost x.x.x.x:80>
ServerName private.mysite.com
DocumentRoot /var/www/private-mysite/html/
ErrorLog /var/www/private-mysite/logs/error.log
CustomLog /var/www/private-mysite/logs/access.log combined
</VirtualHost>
/etc/apache2/sites-available/mysite contents:
<VirtualHost x.x.x.x:80>
ServerName www.mysite.com
ServerAlias mysite.com
DocumentRoot /var/www/mysite/
ErrorLog /var/www/mysite/logs/error.log
CustomLog /var/www/mysite/logs/access.log combined
</VirtualHost>
VirtualHostaddress declaration not matching theNameVirtualHostblock. And it may be a good idea to accept some answers to your older questions. – Shane Madden May 27 '11 at 15:11