1 2 Previous Next 21 Replies Latest reply: May 14, 2007 5:35 PM by bradimmanuel
Tom Ropers Level 1 Level 1 (25 points)
I have a fresh install of Mac OS X 10.4 Server, and am having some problems setting up virtual hosts. I have 2 sites I'd like to host. Both are configured under the Sites tab of Web services. Both are pointing to different web folders. Both are using the same IP (the only IP this server has), and both are using port 80.

Regardless of which site I try to access, I always get the first sites default page. I've already checked to make sure it's not a caching issue, and I have turned on the vhostaliasmodule.

I've read through some old posts on this subject, but haven't found a solution that works yet. Any one know how to resolve this? Thanks!

Mac OS X (10.4.8)
  • 1. Re: Virtual Hosts Issues
    Camelot Level 8 Level 8 (45,790 points)
    If you have multiple sites configured on the same IP address and port, then the hostname in the http request has to match the name of the site.

    This means that if you've setup your second site as 'someother.com', then that's the URL you have to request: http://someother.com/
    If you use any other hostname (e.g. http://www.someother.com/ ) it won't work since the name doesn't match.

    If the name doesn't match then the default site will be used.
  • 2. Re: Virtual Hosts Issues
    Tom Ropers Level 1 Level 1 (25 points)
    I know that. I am trying to access the second site via it's correct name, not adding or dropping any portion of it. That's why this is weird- I've set up virtual hosts before on non-Mac OS X servers, but it just doesn't seem to work here...
  • 3. Re: Virtual Hosts Issues
    Camelot Level 8 Level 8 (45,790 points)
    Try removing the IP address from the site configuration. Since you only have one IP address on the box it isn't necessary. As long as the sites have different names you should be OK.
  • 4. Re: Virtual Hosts Issues
    Tom Ropers Level 1 Level 1 (25 points)
    I've tried that. In fact, when I first set the two sites up, I left both of them set with "Any" IP. That didn't work, so I tried setting each to the IP of the server. I've also tried having the first site have the server's IP, and the 2nd site to "Any" IP. All no luck.
  • 5. Re: Virtual Hosts Issues
    Roger Smith3 Level 6 Level 6 (13,475 points)
    Somewhere in that dopey GUI, there's a (I think) checkbox that's supposed to be the default allowing for name based virtual hosting. Perhaps it got unchecked/selected?

    The money line in httpd.conf is NameVirtualHost for name based virtual hosting.

    Just for fun, you may want to run:

    sudo apachectl configtest

    and check /var/log/httpd/error_log

    Those should point you to the problem.

    Roger
  • 6. Re: Virtual Hosts Issues
    Tom Ropers Level 1 Level 1 (25 points)
    I did make sure to enable the virtual host module. I think that's what you're talking about with a checkbox in the GUI, anyway.

    I ran that test, and the results didn't show any errors- just a number of warnings that look like:

    [Thu Dec 21 21:27:21 2006] [warn] long lost child come home! (pid 552)

    They all had different timestamps and different pid's. From the timestamps, it would appear that these are all from when I was testing the config trying to get it to work a few days ago.
  • 7. Re: Virtual Hosts Issues
    Roger Smith3 Level 6 Level 6 (13,475 points)
    The virtual_host module just introduces the concept of virtual hosts to the core Apache server. It doesn't do anything towards selecting name based or IP based virtual hosting.

    TBH, I know that name based virtual hosting is the default setup in Apple's implementation. The times that I've tried to use the stupid GUI, all it's done is anger me so I just edit the files by hand. I'm not really familiar with the GUI.

    Roger
  • 8. Re: Virtual Hosts Issues
    Celia Wessen Level 4 Level 4 (1,155 points)
    Sometimes working late at night, I forget to check the "Active" box next to the site's name.

    Try this. Deactivate the first site that keeps on appearing and Activate the other site that doesn't work for you. Restart the Web service and see if you can now view the second site. If not, you've got some config problems within the second site.
  • 9. Re: Virtual Hosts Issues
    Svenkin Level 1 Level 1 (0 points)
    Hi Tom,

    I was having the same problem, I set both ip addresses to "wildcards" or to "any" in the drop-down menu box. This solved the problem for me.

    Warren
  • 10. Re: Virtual Hosts Issues
    Tom Ropers Level 1 Level 1 (25 points)
    I tried deactivating the first site, and now the other site is loaded regardless of which URL I use. So it appears that the second site is configured fine, just the virtual hosts don't seem to want to work.
  • 11. Re: Virtual Hosts Issues
    Tom Ropers Level 1 Level 1 (25 points)
    Setting both sites to use "Any" didn't change a thing- only the first site loads regardless of which URL I use.
  • 12. Re: Virtual Hosts Issues
    Celia Wessen Level 4 Level 4 (1,155 points)
    Are you comfortable with pico? Using the Terminal.app, open the file /etc/httpd/sites/virtualhostglobal.conf.

    You should see a line similar to:
    Name Virtualhost 123.123.123.123:80

    with your IP address.

    Make sure that this line is not commented out with the "#" sign.

    If you do not have this file, don't worry, it's not hard to recreate.


    Extended Keyboard Server   Mac OS X (10.4.7)  
  • 13. Re: Virtual Hosts Issues
    Tom Ropers Level 1 Level 1 (25 points)
    That file exists, but the entry has an asterisk instead of the local machine IP right now. I'm assuming that if I change this is the GUI it would change in this file.
  • 14. Re: Virtual Hosts Issues
    Tom Ropers Level 1 Level 1 (25 points)
    Ha!
    I finally figured it out.

    In httpd.conf, at the end of the file there's a section stating to use all of the .conf files in the /etc/httpd/sites directory. Seemingly, Mac OS X Server sets up every site as a virtual host, and creates a .conf file for each site in this directory. The issue ended up being that the directive in http.conf was:

    Include "/etc/httpd/sites/*.conf"

    I removed the quotes and both of my virtual hosts are working now.

    I don't know if this is a bug, or if there's supposed to be some other way to make this work.

    Thanks for the help from all of you!
1 2 Previous Next