Re: Handling VirtualDocumentRoot inside VirtualHosts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Alberto Giménez wrote:
> (First of all, sorry for my english, its not my native language so you
> can read some basic/strange language constructions here :)
>
> Hi, I'm facing a problem with my Apache (1.3.33) setup, I expose the
> scenario:
>
> One single machine is serving several domains (about 300 or so). One
> of them has thousands of visits a day (95% of daily load) and the
> other domains have very low traffic.
>
> I use awstats to parse the access_log file and get visit stats on a
> daily basis, but it's growing up a lot. I parse the logfile with
> awstats_updateall, and what it does is just parse the same log again
> and again for each domain (remember, about 300)
>
> So, I have an access_log with 95% of hits for only one domain, and the
> other 300 domains are parsing the same big BIG file to just get 10
> hits or so. It is very inefficient, isn't it?
>
> The current setup is with a VirtualDocumentRoot directive on server
> environment, so all domains are treated the same way. And I'd like to
> distinguish the main domain from the oters so parsing speeds up and
> gets more effective:
>
> Hits to main domain go to one access_log file
> Hits to any other domain go to *one* single access_log file, so calls
> to awstats are against this only logfile. This way I get smaller file
> (and quicker to parse) for the 300 domains.
>
> I got a working setup but I doutbt if it works because I configured it
> properly, or is kind of "collateral" effect of apache conffile-parsing
> (This is a local network machine, i didn't test it in production
> environment :):
>
> NameVirtualHost 192.168.0.150
> UseCanonicalName Off
> LogLevel debug
>
>
> <VirtualHost 192.168.0.150>
>        VirtualDocumentRoot /var/www/sites/%-2.1/%-2.2/%-2.3/%-2.0.%-1/
>  DirectoryIndex index.php index.html
>  CustomLog /var/log/apache/webs_access_log vspecial
> </VirtualHost>
>
>
> <VirtualHost 192.168.0.150>
>        ServerName www.portal.com
>        ServerAlias portal.com
>        DocumentRoot /var/www/portal/
>        CustomLog /var/log/apache/access_log vspecial
>        DirectoryIndex index.html index.cgi index.pl index.php
> </VirtualHost>
>
> I deduced that, as I use the ServerName directive, it just matches the
> second VirtualHost if the request is *only* to that name, and uses the
> first one in all other cases. Is that correct? Is that setup OK, or is
> it working accidentally??
It is correct, I useDCMVH too, just like you I have 1 main with
thousands and a hundred smaller ones, I do exactly what you do to
separate them - two access log files, except that I also have two error
logs as well.
>
> I tried several combinations:
> If I switch Vhosts definition order, it doesn't work.
I dont understand why, if the host matches it should use whatever
virtualhost has that servername, whatever the order
> If I use <VirtualHost www.abcd.com> in the first entry, it works also
> for all domains (why? because it is the first one and therefore the
> default?).
anything which doesnt match a hostname will use the first defined
virtualhost,

I do not have
<VirtualHost 192.168.0.150>
       VirtualDocumentRoot /var/www/sites/%-2.1/%-2.2/%-2.3/%-2.0.%-1/
 DirectoryIndex index.php index.html
 CustomLog /var/log/apache/webs_access_log vspecial
</VirtualHost>

I only have

 VirtualDocumentRoot /var/www/sites/%-2.1/%-2.2/%-2.3/%-2.0.%-1/
 DirectoryIndex index.php index.html
 CustomLog /var/log/apache/webs_access_log vspecial

at the end after all my virtualhost definitions
>
> Could someone please throw some light? I've been searching for mass
> virtual hosting with separate logs (not for ALL, but the setup I
> exposed here) but didn't find nothing interesting, and I found Apache
> documentation a little poor on that topic. Does anyone have a pointer
> on how does apache treat internally all the vhosts thing?
you are doing fine, this is how it works, and you can define every other
thing there as well, you can have custom rewrites, bandwidth rules, but
the trick is, every time you want a particular servername to be
configured different you have to supply a virtualhost definition to go
with the new rules.

matt
>
> Thanks in advance!
>




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux