Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: updated to new standards

...

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

Start with the default virtual host file as a template as it changes over time,

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

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

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

    ServerName www.krypton.com
    ServerAlias krypton.com

    DocumentRoot /opt/web/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 /opt/web/www.krypton.com/www/>
        Options +MultiViews
        Order Allow,Deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/www.krypton.com.error.log

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

    CustomLog ${APACHE_LOG_DIR}/www.krypton.com.access.log combined

</VirtualHost>

...

Just because you created the virtual host does not mean it is enabled. To enable the virtual hosting,

Code Block
languagebash
cd /etc/apache2/sites-available/ # must be in this directory for a2ensite to work
sudo a2ensite www.krypton.com.conf # enable a virtual host
sudo a2ensite www.earth.com.conf # enable a virtual host
Info

As an side note, a2ensite is a Ubuntu shortcut command which creates a symbolic link. It is exactly the same things as doing this,

cd /etc/apache2/sites-enabled/
sudo ln -s ../sites-available/krypton.com ./krypton.com

...