Apache Help

Brian Densmore DensmoreB at ctbsonline.com
Fri Mar 1 18:15:03 CST 2002


I have never seen that style before, perhaps I Bob is right
and I just haven't seen that form before. It is probably because of
the "NameVirtualHost *" that requires your form. That's the good/bad
thing about apache, there are so many possible configurations that
there can be multiple paths to the right answer, and that answer may not
always be the same. My humble apologies to Bob.

BTW: This also works, Mike, just make sure you qualify the name of the
domain 
fully in the manner people will be viewing it. Also Lucas can you access
your 
virtual sites both with and without the "www"? Just want to see if your
solution 
has benefits mine does not.
 
NameVirtualHost <ipaddress>:80

<VirtualHost www.aMason.net:80>
DocumentRoot /home/aMason/html
ServerName www.aMason.net
ServerAdmin webmaster at aMason.net
ErrorLog /usr/local/apache/logs/error_log
TransferLog /usr/local/apache/logs/access_log
ScriptAlias /protected-cgi-bin/ /home/aMason/protect-cgi-bin/
User nobody
Group nobody
Options Indexes
ServerPath /aMason
</VirtualHost>

<VirtualHost www.RoseFire.org:80>
ServerAdmin brianjd at RoseFire.org
ServerName www.RoseFire.org
ServerAlias www.RoseFire.org
DocumentRoot /home/RoseFire/html
ErrorLog /usr/local/apache/logs/error_log
TransferLog /usr/local/apache/logs/access_log
ScriptAlias /protected-cgi-bin/ /home/RoseFire/protect-cgi-bin/
User nobody
Group nobody
Options Indexes
ServerPath /RoseFire
</VirtualHost>

-----Original Message-----
From: Lucas Peet [mailto:lpeet at eccod.com]
Sent: Friday, March 01, 2002 11:55 AM
To: Brian Densmore
Cc: KC Linux Group
Subject: Re: Apache Help

...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:

### Begin httpd.conf ###

NameVirtualHost *

<VirtualHost www.domain1.com>
...
</VirtualHost>

<VirtualHost www.domain2.com>
...
</VirtualHost>

### End httpd.conf ###

After restarting apache (/sbin/service httpd restart) here's the error:

Starting httpd: [Fri Mar  1 11:20:28 2002] [warn] VirtualHost
www.eccod.com:80 overlaps with VirtualHost www.riodo.ath.cx:80, the
first has precedence, perhaps
you need a NameVirtualHost directive
[Fri Mar  1 11:20:28 2002] [warn] NameVirtualHost *:80 has no
VirtualHosts

and going to www.domain1.com works just fine, but when going to
www.domain2.com, you still get www.domain1.com.

Michael, here's what you need:

### Begin sample httpd.conf ###
# note it doesn't matter what you put for the *server* settings above
the virtual host lines, as
# that's all ignored if you use virtual hosts.  (i.e. leave the modules,
etc...)

NameVirtualHost *

<VirtualHost *>
     ServerAdmin email at domain1.com
     DocumentRoot /www/domain1.com/htdocs
     ServerName www.domain1.com
     ErrorLog logs/error_log
     CustomLog /www/domain1.com/logs/access_log common
     CustomLog /www/domain1.com/logs/referer_log referer
     CustomLog /www.domain1.com/logs/agent_log agent
     CustomLog /www.domain1.com/logs/access_log combined
</VirtualHost>
     ServerAdmin email at domain2.com
     DocumentRoot /www/domain2.com/htdocs
     ServerName www.domain2.com
     ErrorLog /www/domain2.com/logs/error_log
     CustomLog /www/domain2.com/logs/access_log common
     CustomLog /www/domain2.com/logs/referer_log referer
     CustomLog /www.domain2.com/logs/agent_log agent
     CustomLog /www.domain2.com/logs/access_log combined
<VirtualHost *>

### End sample httpd.conf ###

After a restart of Apache, there are no errors (or warnings), just a
clean stop, start.

As the Apache documentation says..."Just about every directive can be
placed inside a <VirtualHost *> directive."  So, your directory
directives, access directives, etc...they all go  inside each
<VirtualHost *> directive.

This, at least, works for me, and it works great.  I'm hosting 3 sites
this way and have had no problems whatsoever.  For those who are
interested, or want to know, I have Apache configured for both php and
Apache::ASP (with mod_perl).  One of my sites is done in PHP, and the
other is written in Perl/ASP.

-Lucas

Brian Densmore wrote:

Bob, you're wrong, his statements are correct. But as Charles
pointedout,Mike needs to add "www" to all of his lines, or try accessing
the siteswith http://domain1.com http://domain2.com .I tested this out
on my site and that is exactly what the problem is.If I enter
http://www.amason.net/ I get the amason site,if I enter
http://www.rosefire.org/ I get the rosefire site,if I enter
http://amason.net/ I get the amason site,if I enter http://rosefire.org
I get the =-amason-= site! :)Thanks Charles for the tip.Brian
-----Original Message-----From: Bob Stocker
[mailto:bstocker at bloodtip.org]Sent: Thursday, February 28, 2002 10:22
PMTo: Michael PrattCc: kclug at kclug.orgSubject: Re: Apache HelpOn Thu,
2002-02-28 at 21:36, Michael Pratt wrote:
This is Driving me bonkers!  IF I get rid od the primary 
website out of the
virtual directory It works but if I add it back in all that 
comes up on both
Domains it the Primary domain!!! UUUUUUHHHHHHHG!!!!! :((((((Mike
Hi there,You're using the VirtualHost directive incorrectly.The form
should be <VirtualHost [IP address]> rather than
<VirtualHost[hostname]>.  So, for your purposes you could do
<VirtualHost *> or<VirtualHost [DSL IP address]> for each of your
virtual hosts.From
http://httpd.apache.org/docs-2.0/vhosts/name-based.html :"Now when a
request arrives, the server will first check if it is usingan IP address
that matches the NameVirtualHost. If it is, then it willlook at each
<VirtualHost> section with a matching IP address and try tofind one
where the ServerName or ServerAlias matches the requestedhostname. If it
finds one, then it uses the configuration for thatserver. If no matching
virtual host is found, then the first listedvirtual host that matches
the IP address will be
 used."Good luck,Bob
----- Original Message -----From: "Brian Densmore"
<DensmoreB at ctbsonline.com>To: <mtpratt at swbell.net>;
<kclug at kclug.org>Sent: Thursday, February 28, 2002 12:21 PMSubject: RE:
Apache Help
Mike,  What does your: listen , bindaddress,
usecanonicalname,hostnamelookups lines look like?  Also what about the 
directory settings
lines. You might try adding a document root line in each 
of the virtual
domains.brian
-----Original Message-----From: Michael Pratt
[mailto:mtpratt1971 at hotmail.com]Sent: Thursday, February 28, 2002 11:56
AMTo: kclug at kclug.orgSubject: Apache HelpI am trying to set up multiple
domains using one IP  I havethis in myhttpd.confNameVirtualHost <DSL IP
ADDRESS><VirtualHost domain1.net>DocumentRoot /var/www/htmlServerName
domain1.net</VirtualHost><VirtualHost domain2.org>DocumentRoot
/var/www/html/domain2ServerName domain2.org</VirtualHost>The problem I
have is no matter what domain I put in it goesto domain1.nethow can I
set Apache up to point Domain1 to /var/www/html andDomain2
to/var/www/html/domain2?Thanks!Mike
                        
_________________________________________________________________
MSN Photos is the easiest way to share and print your
photos:http://photos.msn.com/support/worldwide.aspxKC Linux Users Group
majordomo at kclug.org
majordomo at kclug.org
majordomo at kclug.orgEnter without the quotes in body of message
majordomo at kclug.orgEnter without the quotes in body of message




More information about the Kclug mailing list