Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Next you create your physical virtual host file in /etc/apache2/sites-available and then create a symbolic link in /etc/apache2/sites-enabled/.

Use the default virtual host file as a template

Code Block
langhtml
cd /etc/apache2/sites-available
sudo cp default www.krypton.com
sudo cp default www.earth.com

sudo Edit www.krypton.com and remove all the extra lines and modify the matching lines,

Code Block
langhtml
<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    ServerName www.krypton.com
    ServerAlias krypton.com

    DocumentRoot /home/www.krypton.com/www

    # This restrictive a precedence for ALL directory blocks.
    <Directory />
        Options FollowSymLinks
        # This prevents use of .htaccess
        AllowOverride None   
    </Directory>

    # Main location of static content for the websites.
    <Directory /home/www.krypton.com/www/>
        Options +MultiViews
        Order Allow,Deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/www.krypton.com.error.log

    # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/www.krypton.com.access.log combined

</VirtualHost>

Some notes on not so obvious entries in the virtual host file,

  • MultiViews - uses Content Negotiation choose the best representation of a resource based on the browser-supplied preferences for media type, languages, character set and encoding.
  • A keen eye will notice the +MultiViews. The plus symbol indicates we are adding to the existing Options inherited from parent blocks rather than resettting.
  • combined - This is a predefined log format set by LogFormat in apache2.conf

Note that there is a disadvantage with specifying specific log files per virtual hosts because you can run out of file descriptors. The pro of course is simplicity and easy separation of your logs. Ther may be alternatives but don't hold your breath for me to write about this. My clients rarely keep more than 3 virtual sites on the same machine.

Warning

This article is still being transitioned from my old google wiki.