I am trying to figure out what determines the "default" website on a webserver.

I am running a Ubuntu 10.04 webserver that hosts 5 different websites.

In my apache2/sites-available folder there is an entry like this for each of the 5 sites:

<VirtualHost *:80>
ServerName mysite.ca
ServerAlias www.mysite.ca
ServerAdmin daniel@mysite.ca
DocumentRoot /home/sites/Dropbox/mysite.ca/
  <Directory /home/sites/Dropbox/mysite.ca/>
        Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>
</VirtualHost>

When I try to access this webserver via IP address from a computer that is behind the firewall and within Active Directory, the webpage for one of the sites loads, but I would prefer to load a different site. How can I control which site loads by default on my webserver?

link|improve this question
feedback

2 Answers

It loads the first available VirtualHost which is simple the order they are placed in your configuration file. You can check the order by typing apache2ctl -S on the commandline of your server.

To change this, you can re-order the VirtualHost container, or simply create some sort of "default".

link|improve this answer
feedback

Usually on my installs I add a file named 00_Default_Site on the /etc/apache2/sites-available/ and add the Default Vhost config on it.

As soon as you don't add any other config file that could have precedence on a name sorting, it will always be the first config file to be included, and because that, the first to load and the one that will behave as default.

link|improve this answer
Thanks @Leon. I want to try your suggestion, but I'm still a little unclear where to begin. Could you help explain a bit more? I made the entry that you suggested, but it is not working. Do I need to restart anything after making the entry? – DanielAttard Jan 31 at 16:31
ok, I just did $ sudo /etc/init.d/apache2 restart to restart the server and now it is partially working. Now I am getting the right site to load, but it is not loading the CSS. Weird. – DanielAttard Jan 31 at 16:34
Did you remembered to activate the site? Try a "sudo a2nsite 00_Default_Site" and it should be enabled. – Leon Waldman Feb 1 at 8:34
Thanks again @Leon. I think there was a typo in your code. It should be a2ensite, you were missing the 'e'. That being said, when I ran the code it told me that the site is already enabled. The site loads for me, but doesn't load any CSS or JS. Wish I knew why. – DanielAttard Feb 1 at 15:02
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.