Configure Apache with Virtual Hosts
The minimal Ubuntu 8.0.4 package from A2 Hosting comes with Apache 2 preinstalled, but it does not come with mod_rewrite enabled (which is necessary for all applications built with the Istarel Workshop Application Framework).
sudo a2enmod rewrite sudo /etc/init.d/apache2 force-reload
Virtual Hosts
I intend to host several domains on this Virtual Private Server, and Apache and Ubuntu make it very straightforward to handle mutiple domains through a mechanism called Virtual Hosts. Essentially, you use the IP Address of the server as the "host" (using the NameVirtualHost directive) and then provide a configuration file for each hosted domain which establishes its identity in the context of the main "host".
Partial Listing: /etc/apache2/apache.conf
NameVirtualHost 74.126.25.201:80 Include /etc/apache2/sites-enabled/
I want istarelworkshop.com to be the foremost hosted domain. I need to create its configuration file in /etc/apache2/sites-available.
Listing: /etc/apache2/sites-available/istarelworkshop.com
<VirtualHost 74.126.25.201:80> ServerName istarelworkshop.com ServerAlias www.istarelworkshop.com ServerAdmin admin@istarelworkshop.com DocumentRoot /var/www/istarelworkshop.com <Directory /var/www/istarelworkshop.com> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/istarelworkshop-error.log LogLevel warn CustomLog /var/log/apache2/istarelworkshop-access.log combined ServerSignature On </VirtualHost>
The AllowOverride is set to all so that Apache will look for (and respect) .htaccess files in the /var/www/istarelworkshop.com directory. That file is where the mode_rewrite rules are given.
To enable this virtual site, I need to create a symbolic link to the sites-avaialble configuration in its sibling sites-enables directory (which is what is actually referenced in the main Apache configuration file). Once Apache is restarted, any visitor navigating to www.istarelworkshop.com will be served pages from /var/www/istarelworkshop.com.
cd /etc/apache2/sites-enabled sudo ln -s ../sites-available/istarelworkshop.com 001-istarelworkshop.com sudo /etc/init.d/apache2 restart