So, I have two web applications on one server. I have a main one which is served when the regular domain is used, but I want a subdomain to point to the other app.
I have set up virtual hosts in the way that I have determined they should be with what I have found in google searches, but it still doesn't work. The subdomain just serves up the main app. Here is the contents of my config file.
<VirtualHost *:80>
ServerName www.luketimoth.me
DocumentRoot /var/www/luketimothy/public
<Directory /var/www/luketimothy/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.luketimoth.me
DocumentRoot /var/www/shattered-plays/public
ServerAlias shattered.luketimoth.me
<Directory /var/www/shattered-plays/public>
PassengerEnabled on
</Directory>
</VirtualHost>
As far as I am aware (with my beginner/rudimentary knowledge of Apache) this should do what I am expecting it to... but it's not. What am I doing wrong?
Output of httpd -S
httpd: apr_sockaddr_info_get() failed for LMTServe
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Sat May 17 16:42:02 2014] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 www.luketimoth.me (/etc/httpd/conf/httpd.conf:1017)
*:80 www.luketimoth.me (/etc/httpd/conf/httpd.conf:1031)
Syntax OK
EDIT:
I have changed the virtual host to use the desired subdomain as the ServerName, but I am still seeing the same problem.
<VirtualHost *:80>
ServerName www.luketimoth.me
DocumentRoot /var/www/luketimothy/public
<Directory /var/www/luketimothy/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName shattered.luketimoth.me
DocumentRoot /var/www/shattered-plays/public
<Directory /var/www/shattered-plays/public>
PassengerEnabled on
</Directory>
</VirtualHost>
httpd: apr_sockaddr_info_get() failed for LMTServe
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Sun May 18 10:15:24 2014] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 www.luketimoth.me (/etc/httpd/conf/httpd.conf:1017)
*:80 shattered.luketimoth.me (/etc/httpd/conf/httpd.conf:1031)
Syntax OK
Both of your virtualhosts are configured for the same servername. Use the desired sub domain for the second.