...
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 Start with the default virtual host file as a template as it changes over time,
Code Block | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
<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/${APACHE_LOG_DIR}/www.krypton.com.error.log # Possible values include: debug, info, notice, warn, error, crit, alert, emerg. LogLevel warn CustomLog /var/log/apache2/${APACHE_LOG_DIR}/www.krypton.com.access.log combined </VirtualHost> |
...
Repeat for www.earth.com changing the directory and domain names values as required.
Note |
---|
Somebody drop in here command line to do this quickly with sed. |
Enable Virtual Host
Just because you created the virtual host does not mean it is enabled. To enable the virtual hosting,
Code Block | ||
---|---|---|
| ||
sudo a2ensite www.krypton.com # enable a virtual host sudo a2ensite www.earth.com # enable a virtual host |
...