Women in Technology

Hear us Roar



Article:
  Apache Web-Serving with Mac OS X, Part 6
Subject:   what about Virtual Hosts?
Date:   2002-09-18 11:22:37
From:   tatlar
Kevin,


Love the articles! They have helped me no end.


However, I would really like to see some info on setting up Virtual Hosts - I have tried to do this already, but without success, and have had to shelf the project and put up with the error messages I am getting! Apple's OS X Server help pages are useless, and I like your style.


Any chance of some tips???


Keep up the good work,


- Tatlar

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • what about Virtual Hosts?
    2002-10-10 22:31:02  kiddailey [View]

    I forgot to mention that this change affects even your localhost and ip-based urls... so typing in http://localhost or the localhost ip will try to look for a corresponding folder :)

    It's not perfect, but it works!
  • How to setup virtual hosts
    2002-10-10 22:24:36  kiddailey [View]

    Tatlar:

    I grew impatient and figured out a way to do this myself -- it was extremely easier than I thought it would be. Standard disclaimer applies: it worked for me, but I take no responsibility :)

    Step 1:
    -------

    Load up your http.conf file (/etc/httpd/httpd.conf) in your favorite text editor, and uncomment the following lines by removing the pound sign (#):

    #LoadModule vhost_alias_module libexec/httpd/mod_vhost_alias.so

    #AddModule mod_vhost_alias.c


    Step 2:
    -------

    Search for the following line:

    UseCanonicalName On

    ... and turn it off by changing it to:

    UseCanonicalName Off


    Step 3:
    -------
    Add the following line right below the last one you modified in step 2:

    VirtualDocumentRoot /Library/WebServer/Documents/%0

    Basically this says reroute to the folder that matches the server name. i.e. http://www.foo.com -> /Library/WebServer/Documents/www.foo.com/ In theory, you could use any folder, but I chose to simply repurpose my webserver documents directory.


    Step 4:
    -------
    Save the file and restart your web server (turn web sharing off and then on again).


    Now the trick to getting this to work completely is to simply create folders for each domain name you want to host virtually. For example, say you have two sites: www.foo.com and www.bar.com. In your webserver documents folder, you'd simply create folders with the same names:

    /Library/WebServer/Documents/www.foo.com
    /Library/WebServer/Documents/www.bar.com

    And put the files for each site in the respective folders.

    Magic!

    Note that you might need to tweak this to get www.foo.com and foo.com to point to the same place (using aliasing, I'd imagine). You can read all about the vhost_alias module and VirtualDocumentRoot directive at http://httpd.apache.org/docs/mod/mod_vhost_alias.html
    • How to setup virtual hosts
      2007-03-08 11:23:01  jepler@hotmail.com [View]

      kiddailey:

      Did you do anything in the OS X Server Sites area of the Server Admin GUI before (or after) you got this to work?

      Thanks,

      -Jim
      San Diego, CA