I've ran into this problem before with other flavors of Linux and typically it's something dumb but I think I've ruled out all those possibilities. I an using multiple virtual hosts on apache2 Ubuntu 12.10. As per Ubuntu default setup:
[ports.conf]
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Apache2.conf is ubuntu default and loads ports.conf.
I have two virtualhosts
<VirtualHost *:80>
ServerName *.staging.mydomain.com
Options -Indexes FollowSymLinks
UseCanonicalName Off
DocumentRoot /var/www/staging/app/application/current/app
ErrorLog "/var/log/error.log"
CustomLog "/var/log/custom_error.log" common
<ifModule env_module>
SetEnv PHP_ENV staging
</ifModule>
<Directory />
AllowOverride none
</Directory>
<Directory "/var/www/staging/app/application/current/app">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName *.devtest.mydomain.com
Options -Indexes FollowSymLinks
UseCanonicalName Off
DocumentRoot /var/www/devtest/app/application/current/app
ErrorLog "/var/log/error.log"
CustomLog "/var/log/custom_error.log" common
<ifModule env_module>
SetEnv PHP_ENV develop
</ifModule>
<Directory />
AllowOverride none
</Directory>
<Directory "/var/www/devtest/app/application/current/app">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</Directory>
</VirtualHost>
A request to somevalue.devtest.mydomain.com resolves to the same document root as somevalue.staging.mydomain.com. If I flip the order the VirtualHosts are declared in then this works in reverse; a request to somevalue.staging.mydomain.com will resolve to the same document root as somevalue.devtest.mydomain.com. No matter what I've tried, I cannot get both hosts to work at the same time. I have this working locally on WAMP and had this same issue but it was simply a misplaced NameVirtualHost *:80 that made it work. Moving the Listen and NameVirtualHost out of ports.conf into apache2.conf and removing the Include for ports.conf does not help. Apache generates no errors. Log level is set to debug.
And because I know you'll ask, yes I have enabled these sites using a2enmod. Yes, I have rebooted apache. I've gone so far as to reboot the server entirely. If I enable the default virtualhost that comes with ubuntu $sudo a2enmod default
then it will catch all requests for both somevalue.devtest.mydomain.com and somevalue.staging.mydomain.com.
The virtual hosts are enabled and resolving $sudo apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server *.staging.mydomain.com (/etc/apache2/sites-enabled/wild.mydomain.com:19)
port 80 namevhost *.staging.mydomain.com (/etc/apache2/sites-enabled/wild.mydomain.com:19)
port 80 namevhost *.devtest.mydomain.com (/etc/apache2/sites-enabled/wild.mydomain.com:51)**strong text**
And finally, the requests resolve on the server curl -Lv http://test.staging.mydomain.com
* About to connect() to test.staging.mydomain.com port 80 (#0)
* Trying 1.1.1.1...
* connected
* Connected to test.staging.mydomain.com (1.1.1.1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.27.0
> Host: test.staging.mydomain.com
> Accept: */*
>
* additional stuff not fine transfer.c:1037: 0 0
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
< Date: Tue, 05 Mar 2013 02:22:28 GMT
< Server: Apache/2.2.22 (Ubuntu)
< X-Powered-By: PHP/5.4.6-1ubuntu1.1
< Vary: Accept-Encoding
< Content-Length: 18
< Content-Type: text/html
<
* Connection #0 to host test.staging.mydomainy.com left intact
<pre>staging</pre>* Closing connection #0
I've removed the IP and domain but it's definitely resolving properly. Everything on the servers run fine and in fact I didn't even notice the issue until I was on the staging environment and noticed data being updated on the devtest domain instead of staging.
I normally do not ask for any help on here and I've scoured the web and Stack Overflow alike. This does not seem to be a problem with incorrect port names, not declaring ServerName in the VirtualHosts, or not declaring the NameVirtualHost *:80 or Listening on the correct port. I'm completely stumped. Also, this same configuration works on an RPM based version of Linux.