Re: apache virtual host configuration...




On 4-jul-2008, at 10:05, Dietrich Bollmann wrote:

Hi,

The syntax for virtual hosts configuration seems to have changed...

Until now I used the following syntax:
(taken from the configuration files in /etc/apache2/sites-enabled/)

<VirtualHost *:80>
...
</VirtualHost>

<VirtualHost *>
ServerName foo.bar
...
</VirtualHost>

...which seems to not work anymore.

I could make the virtual host foo.bar work again by
changing the second configuration to

<VirtualHost foo.bar>
ServerName foo.bar
...
</VirtualHost>

but now even http://localhost/ is directed to the default
page of the virtual host foo.bar...

How do I have to change the apache configuration files
to make things work again?




It's a little unclear what you're trying to accomplish, but I think you simply want one site for http://foo.bar and have any other request go to a default page. In that case you create two files in / etc/apache2/sites-available, one for the general site and one for the other. Both use the syntax:

<Virtualhost *:80>
Servername
...
</Virualhost>

So both user '*:80' and both have a servername, since that won't be used to control the order in wich apache uses them to process requests. Then you use the command a2ensite (man a2ensite) to enable you sites, making sure they're in the right order, i.e. the default site first, the other last. The easiest way to do that is to use number prefixes in their names. That way, if the url is not known, apache will simply use the first file it finds in de sites dir and all your request that don't contain 'foo.bar' go to the default site.


HTH


Peter


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: natted apache2 virtual hosts
    ... > my configuration is below. ... > lynx like so: ... ServerName, but that may have been due to my nameless worm catching ... > Syntax OK ...
    (comp.unix.bsd.freebsd.misc)
  • apache virtual host configuration...
    ... The syntax for virtual hosts configuration seems to have changed... ... ServerName foo.bar ... I could make the virtual host foo.bar work again by ...
    (Debian-User)
  • Re: [opensuse] Re: apache mod_rewrite
    ... # Global configuration that will be applicable for all virtual hosts, ... # AllowOverride controls what directives may be placed in .htaccess files. ... # Controls who can get stuff from this server. ... # certain virtual host, but not here. ...
    (SuSE)
  • Re: Adding multiipul virtual domains?
    ... Apache Web Server ... Mod PERL ... When I add a new virtual host I would like the host to have it's own ... configuration management system or to modify the configuration files ...
    (freebsd-stable)
  • Re: Adding multiipul virtual domains?
    ... Apache Web Server ... Mod PERL ... When I add a new virtual host I would like the host to have it's own ... configuration management system or to modify the configuration files ...
    (freebsd-stable)