I'm trying to deploy a python/flask application on an apache2 installation on ubuntu (14.04), following the instructions at the link
The application seems to work and if I point the browser to http://mywebsite.com/
I correctly see the message returned by the Flask application.
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 http://mywebsite.com/FlaskApp
, while having the possibility to define another virtual host at http://mywebsite.com/MyOtherWebApp
This is the FlaskApp.conf file as per instructions on the mentioned article:
<VirtualHost *:80>
ServerName mywebsite.com
ServerAdmin admin@mywebsite.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and here is how the /var/www
folder is structured after I installed the python app
/var/www
+-- FlaskApp
¦ +-- FlaskApp
¦ ¦ +-- flaskenv
¦ ¦ +-- __init__.py
¦ ¦ +-- __init__.pyc
¦ ¦ +-- static
¦ ¦ +-- templates
¦ +-- flaskapp.wsgi
¦
+-- MyOtherWebApp
+-- ...
Some notes with more details:
- I don't have the possibility to use different domain names or diffent ports for the different VirtualHost
- I found this thread suggesting to use the directive
ServerAlias
as shown below to solve a similar problem, but if I do this and go tohttp://mywebsite.com/
I see a directory listing of the FlaskApp folder instead of the results of the flask service invocation, as in the screenshot below:
here the changed FlaskApp.conf:
<VirtualHost *:80>
ServerName mywebsite.com/FlaskApp
ServerAlias mywebsite.com/FlaskApp
.
.
.
screenshot: