title: Setting up vhost for various web applications on AWS
body: <p>On my AWS instance, I have the following setup</p>
  
  <pre><code>/var/www/html/admin &lt;--- angularjs application
  /var/www/html/api &lt;--- angularjs application
  /var/www/html/main &lt;--- django application
  </code></pre>
  
  <p>How do I make them all accessible as "individual sites"? For example, browsing to:</p>
  
  <pre><code>http://ec2-xx-xx-xxx-xxx.eu-west-2.compute.amazonaws.com/admin
  http://ec2-xx-xx-xxx-xxx.eu-west-2.compute.amazonaws.com/api
  http://ec2-xx-xx-xxx-xxx.eu-west-2.compute.amazonaws.com/main
  </code></pre>
  
  <p>Should each be like going to a self contained site.</p>
  
  <p>Right now going to <code>http://ec2-xx-xx-xxx-xxx.eu-west-2.compute.amazonaws.com/main</code> for instance (which is an AngularJS application), I see errors like this:</p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404 (Not Found)
  </code></pre>
  
  <p>I logged onto the site and noticed that it thinks the assets live a directory above as opposed to in the "main" subdirectory. I can understand that I need to set up vhosts somehow... where do these go on an AWS instance and would they look like this? </p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin info@main.com
      ServerName main.com
      ServerAlias www.main.com
      DocumentRoot /var/www/html/main
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerAdmin info@main.com
      ServerName main.com/api
      ServerAlias www.main.com/api
      DocumentRoot /var/www/html/api
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ServerAdmin info@main.com
      ServerName main.com/admin
      ServerAlias www.main.com/admin
      DocumentRoot /var/www/html/admin
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>