On an AWS EC2 machine, in my /etc/httpd/conf/httpd.conf
file I had this server configuration:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.example.com
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html/zf2-tutorial/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This is doing a great job of handling "www.example.com" traffic, and when I request "www.example.com/Workstream" I get the application that lives at /var/www/html/Workstream
.
So, feeling good about myself, I decide I want to be fancy and have the web server route "workstream.example.com" traffic to /var/www/html/Workstream
(following the Apache VirtualHost documentation and examples).
So I get the CNAME aliased to the relevant A record--done, working, great. I then set my sights on the httpd.conf file to add this <VirtualHost>
right behind the existing one:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName workstream.example.com
DocumentRoot /var/www/html/Workstream
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
I saved the edit then rebooted apache (sudo /usr/sbin/apachectl restart
-- don't know why my apache isn't where everyone else's is) and pointed a browser at "workstream.example.com" and...got the contents of /var/www/html
. The reboot returned this warning:
[warn] default VirtualHost overlap on port 80, the first has precedence
I'm such a linux noob it's painful. What am I doing wrong? Am I editing the correct httpd.conf (using find / -xdev 2>/dev/null -name "httpd.conf"
I see there's another httpd.conf at /opt/railo/sys/httpd.conf
)? Does the ServerName need to correspond to something I haven't set up? Is my syntax incorrect?
The result of sudo /usr/sbin/apachectl -S
is:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server www.example.com (/etc/httpd/conf/httpd.conf:1005)
port 80 namevhost www.example.com (/etc/httpd/conf/httpd.conf:1005)
port 80 namevhost workstream.example.com (/etc/httpd/conf/httpd.conf:1020)
Syntax OK
/opt/railo/sys/httpd.conf
seems to just be an alias to/etc/httpd/conf/httpd.conf
.