Calliphoridae (pkbarbiedoll) wrote in suse,

  • Music:

Question about apache vhosts

How does Apache determine which of your existing vhosts is the default?

I'm using Apache 2 on Suse 10.0; here are the details:

  • I have two vhost.conf files in /etc/apache2/vhosts/ - fu.vhosts.conf and bar.vhosts.conf.  
  • Both of these were copied from vhosts.template
  • I performed a find and replace on "" to "fu", and "bar", respectively. 
  • I copied web content into /srv/www/vhosts/fu and /srv/www/vhosts/bar
  • No content exists under /srv/www/htdocs

When I type in the IP of the server, the "fu" site appears.   How do I set a another site to appear as the default?

  • Post a new comment


    default userpic
Unless you've actually defined a default site, the first of your vhosts (alphabetically) will be shown when any non-defined website is asked for.

  • If you have an existing or new site that you want to make your default site (shown when any of your domains or your IP that are not defined by a vhosts file is asked for), just rename that site's vhosts file so it is alphabetically the first (I just put a "!" at the beginning of the vhosts filename for that site).

  • If you have an existing site that you also want to come up when the IP is browsed, but not be your default site, just add the IP to a ServerAlias line for the existing site's vhost file.

  • If you have a specific site that will only be shown when the IP is requested by a browser, then create another vhosts file with your IP in the ServerName line instead of a domain name.


May 29 2006, 23:21:25 UTC 10 years ago

I use a number-name pattern for my vhost files.



This way if I create a site whose name is alphabetically in a different order than the current sites. I can ensure the load order.