Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On an AWS EC2 machine, in my /etc/httpd/conf/httpd.conf file I had this server configuration:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin me@me.com
    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 me@me.com
    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
share|improve this question
    
Digging a little further, /opt/railo/sys/httpd.conf seems to just be an alias to /etc/httpd/conf/httpd.conf. –  Jeromy French Sep 17 '13 at 21:56
    
please dump entire config! –  GioMac Sep 20 '13 at 0:41
    
See lVlint67's answer, I agree. –  GioMac Sep 20 '13 at 1:18
    
New problem: each of the answers contained an essential piece of the solution, but I can't split the bounty (meta.stackexchange.com/a/157902/208489). So...I'm going to try to give the answer to one and the bounty to the other. –  Jeromy French Sep 20 '13 at 1:50

3 Answers 3

up vote 2 down vote accepted

Do you have a NameVirtualHost *:80 (see "NameVirtualHost Directive") directive somewhere in your configuration? If not, then it's going to be treated as an IP-based virtual host, which ignores the Host header sent by the browser.

share|improve this answer
    
When I search the contents of the httpd.conf file, I see this line: #NameVirtualHost *:80...so if that's what you're referring to, it's commented out. –  Jeromy French Sep 17 '13 at 21:53
    
Well, there's your problem! –  200_success Sep 17 '13 at 21:57
    
Uncommented, restarted apache--no joy. –  Jeromy French Sep 17 '13 at 22:22

The NameVirtualHost *:80 directive should be what you need to make that error go away. Apachectl picks up on it so my suspicion is that apache is not getting properly reloaded. ...Not to be that guy... but have you tried rebooting?

...

...

The alternative being killing all the httpd pids listed in ps -ef and starting?

share|improve this answer
2  
Totally agree - definitely, there must be a problem with service restart –  GioMac Sep 20 '13 at 1:19
    
Well, "that guy" just fixed the problem. <facepalm /> In my defense, I figured the apache restart was sufficient to have the new settings "take". –  Jeromy French Sep 20 '13 at 1:31
    
generally, MOST people restart apache with init.d scripts /etc/init.d/httpd restart or similar. not exactly sure what your webserver is doing but you should be on the right track to getting it to restart correctly now :p –  lVlint67 Sep 20 '13 at 1:37
    
Ugh. "You may award your bounty in 22 hours". I shall return. –  Jeromy French Sep 20 '13 at 2:10

If all request are cached by one virtualhost, maybe you are missing default virtualhost http://httpd.apache.org/docs/2.2/vhosts/examples.html

<VirtualHost _default_:80>
   DocumentRoot /var/www/html
</VirtualHost>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.