first, thanks for the reply. i apologize for the confusion of my question. i will try to clarify and address the issues in-line and below.
what i am trying to do is use apache's dynamic/mass virtual host in the following manner: to add a host, i would like to simply:
1. create a directory or link in my /var/www/sites/ directory (e.g. example1.org) with the site content
2. add the domain name to /etc/hosts (e.g. 127.0.0.0.1 example1.org)
and have apache start serving up the correct pages for both http://example1.org AND http://www.example1.org .
this is the first problem: unless i create a link with "www.example1.org" to the "example1.org" directory of sites, apache will only server requests to example1.org, not www.example1.org . thus, i am trying to setup some directive to avoid having to make 2 entries (both the domain.org directory AND a www.domain.org link to the directory) to have apache serve both domains.
also, once dynamic/mass virtual hosting is enabled, i can no longer access the "default" site of localhost or 127.0.0.1. i have tried to use a VirtualHost directive to setup a default host (i.e. localhost), but with no luck.
ok, let me try your suggestions.... ok, my results are below in-line:
On Wed, 2009-05-06 at 09:01 +0200, Rainer Frey wrote:
i am trying to do both: server dynamic hosts, and have a default site at localhost.
actually your description of you want to achieve, and what already works is a
bit confusing. Do you want to serve the dynamic hosts only, or do you have
an additional default site?
ok, makes sense after reading your comments.
More comments inline.
On Wednesday 06 May 2009 04:04:39 wayne wrote:
> enable mass/dynamic virtual hosts, allowing each virtual host to be
> accessed via example.com AND www.example.com, without creating a
> VirtualHost directive for each host.
> NameVirtualHost *
This is not needed for dynamic vhosts, and has no influence on the
configuration that is outside any vhost directive.
only the domain works, not www.domain.
> UseCanonicalName Off
> VirtualDocumentRoot /var/www/sites/%0/www
> VirtualScriptAlias /var/www/sites/%0/cgi-bin
> which works fine. i can access all the sites listed in /var/www/sites/
> (once they are added to /etc/hosts of course, in both their
> www.example.com and example.com forms).
So at that point, what does work? Only the domain, or also the www.domain?
Eureka! ok, yes, the solution for the www. problem was to use the directory interpolation you suggested. so now, apache serves for both example1.org AND www.example1.org using a single directory in the /var/www/sites directory. thanks! so simple, sorry i missed that. i though the answer lay in some directive. now on to problem 2...
I assume that the latter does not work. You have two ways:
1. change the directory interpolation of the VirtualDocumentRoot and
VirtualScriptAlias e.g. to /var/www/sites/%-2.0.%-1
that means the directory name is the second last domain part, a dot, and then
the last domain part. This enables www.domain as well as any subdomain that
resolves to your apache.
2. simply symlink the domain directory, e.g. www.domain.tld -> domain.tld and
leave the directory interpolation as is.
i agree, but i was desperate! your interpolation solution above made this attempt to setup a default configuration unnecessary. danke/thanks again!
> then, i attempt to make a
> VirtualHost directive for the default host that lists the alias:
> <VirtualHost *>
> ServerName default
> ServerAlias www.*
wildcards are only supported for the first domain part of the alias AFAIK.
> DocumentRoot /var/www/
I think it is a bad idea to have (Virtual)DocumentRoots of hostzs overlap each
i was hoping both?
> unfortunately this does nothing. the virtual hosts are only accessible
> via their domain names WITHOUT the www. prefix.
What is this this VHost supposed to do? Define the default site, or provide
common configuration for the dynamic vhosts?
ok, again makes sense after reading your comments.
The latter thas not work at all,
dynamic vhosts have nothing to do with a <VirtualHost> container.
ok, that also makes sense. however, i have removed all NameVirtualHost and VirtualHost directives. now, the dynamic virtual hosting still works, but the default sites of localhost / 127.0.0.1 still do not work (i.e. http://localhost and http://127.0.0.1 both return 404). both of these domains work if dynamic virtual hosting is disabled. i also tried setting a "default" DocumentRoot in http.conf, with the same results. any other ideas? i even tried making a "localhost" directory in the /var/www/sites/ directory, still with no luck.
cannot define ServerAliases for the dynamic vhosts at all, use directory
interpolation or symlinks as described above.
> in addition, i can no longer access the default DocumentRoot via
> localhost or 127.0.0.1.
Sure, you defined NameVirtualHost * and <VirtualHost *>. All requests are
directed to VHosts, none reaches the main server configuration
i mainly will be using dynamic hosts, though i would like to have the default localhost site work (if possible) as well. also, i was hoping to be able to customize certain dynamic virtual hosts with specific VirtualHost directives.
> here are my details: running Apache/2.2.8 (Ubuntu) Mar 10 2009 18:09:05
> on Ubuntu Hardy 8.04 with kernel 2.6.24-23 and all latest updates
> applied. i have tried it with/without the default "sites-enabled"
> Debian config, to no luck.
If you use the debian package, I'd recommend using its site configuration
mechanism, it is quite convenient. If you only need the dynamic vhosts, put
the config in the default site. If you have one or more other sites, put the
dynamic vhosts inside a <VirtualHost> with a specific IP address.
thanks again, the first problem is solved thanks to you... and sorry for the confusing questions.
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: firstname.lastname@example.org
" from the digest: email@example.com
For additional commands, e-mail: firstname.lastname@example.org