Apache Help

Dustin Decker dustind at moon-lite.com
Fri Mar 1 19:16:20 CST 2002


On Fri, 1 Mar 2002, Lucas Peet wrote:

> ...I hate to do this, and I don't want this to turn into some petty
> "who's right, who's wrong" thread, but I believe Bob *is* right on the
> <VirtualHost *> directive.  I just finished configuring my server a few
> weeks ago, and had to figure this one out too.  When I tried to put the
> server name in the VirtualHost directive:

Essentially, to be as clear as _ I _ know how to be on this -

NameVirtualHost is used first, like thus:

NameVirtualHost 10.1.1.1:80
It means "I want any requests sent to port 80 on 10.1.1.1 to support
name based virtual host directives", which is to say that if I ask for
"www.foo.com" and it resolves to this IP address, I can distinguish what
to serve the request.  (So I don't end up giving the contents of
bar.com, which may also be hosted by this apache server, to requests for
foo.com.)

Then for each domain I have have pointed to 10.1.1.1 via DNS with an A
record, CNAME or whatever trickery you chose, I use the VirtualHost
directive like this:

<VirtualHost 10.1.1.1>
 ServerAdmin webmaster at whatever.com
    DocumentRoot /var/www/html
    ServerName www.whatever.com
    ErrorLog logs/error_log
    CustomLog logs/access_log common
</VirtualHost>

I can then (provided DNS is done as above for this domain as well) add
yet another if I chose like this:

<VirtualHost 10.1.1.1>
 ServerAdmin webmaster at another.com
    DocumentRoot /var/www/another.com
    ServerName www.another.com
    ErrorLog logs/another.com/error_log
    CustomLog logs/another.com/access_log common
</VirtualHost>

Add as many as you feel your host can handle taking into consideration
your bandwidth, planetary alignments, etc...

Another note:
Earlier in httpd.conf than where I generally stick all of these (which
is near the bottom of the file) it is helpful to have the following
directives:
Listen 10.1.1.1:80
BindAddress *

(if you have multiple nics, you can bind to just one IP addy here vice
the use of * if you like)

I certainly hope this helps out... feel free to contact me off list if
you still can't get it worked out.

Dustin

-- 
A man always needs to remember one thing about a beautiful woman.
Somewhere, somebody's tired of her.




More information about the Kclug mailing list