title: deploy flask application on ubuntu/apache2: virtual host configuration
body: <p>I'm trying to deploy a python/flask application on an apache2 installation on ubuntu (14.04), following the instructions at the <a href="https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-application-on-an-ubuntu-vps" rel="nofollow noreferrer">link</a></p>
  
  <p>The application seems to work and if I point the browser to <code>http://mywebsite.com/</code> I correctly see the message returned by the Flask application.</p>
  
  <p>My problem is, what if I want to install a second site as a different virtual host on the same machine (say a non-python application)?
  What I would like is that the virtual host is mapped to an URL like <code>http://mywebsite.com/FlaskApp</code>, while having the possibility to define another virtual host at <code>http://mywebsite.com/MyOtherWebApp</code></p>
  
  <p>This is the FlaskApp.conf file as per instructions on the mentioned article:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
              ServerName mywebsite.com
              ServerAdmin admin@mywebsite.com
              WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
              &lt;Directory /var/www/FlaskApp/FlaskApp/&gt;
                      Order allow,deny
                      Allow from all
              &lt;/Directory&gt;
              Alias /static /var/www/FlaskApp/FlaskApp/static
              &lt;Directory /var/www/FlaskApp/FlaskApp/static/&gt;
                      Order allow,deny
                      Allow from all
              &lt;/Directory&gt;
              ErrorLog ${APACHE_LOG_DIR}/error.log
              LogLevel warn
              CustomLog ${APACHE_LOG_DIR}/access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>and here is how the <code>/var/www</code> folder is structured after I installed the python app</p>
  
  <pre><code>/var/www
      +-- FlaskApp
      ¦   +-- FlaskApp
      ¦   ¦   +-- flaskenv
      ¦   ¦   +-- __init__.py
      ¦   ¦   +-- __init__.pyc
      ¦   ¦   +-- static
      ¦   ¦   +-- templates
      ¦   +-- flaskapp.wsgi
      ¦
      +-- MyOtherWebApp
          +-- ...
  </code></pre>
  
  <p>Some notes with more details:</p>
  
  <ol>
  <li>I don't have the possibility to use different domain names or diffent ports for the different VirtualHost</li>
  <li>I found <a href="https://stackoverflow.com/questions/7660070/apache-multiple-virtual-hosts-on-the-same-same-ipdiffrent-urls">this</a> thread suggesting to use the directive <code>ServerAlias</code> as shown below to solve a similar problem, but if I do this and go to <code>http://mywebsite.com/</code> I see a directory listing of the FlaskApp folder instead of the results of the flask service invocation, as in the screenshot below:</li>
  </ol>
  
  <p>here the changed FlaskApp.conf:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName mywebsite.com/FlaskApp
      ServerAlias mywebsite.com/FlaskApp
      .
      .
      .
  </code></pre>
  
  <p>screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/8xraz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8xraz.jpg" alt="enter image description here"></a></p>