Running two Flask applications under one AWS instance using Apache

Running two Flask applications under one AWS instance using Apache

Have two application files copied in /var/www

Application 1:- /var/www/apple
Application 2:- /var/www/banana

Create two wsgi files at both the above location with below content:-
apple.wsgi
*************************************
import sys
sys.path.insert(0, ‘/var/www/apple’)

from app import app as application
*************************************
banana.wsgi
*************************************

import sys
sys.path.insert(0, ‘/var/www/banana’)

from app import app as application
*************************************

=================================================================

Create one conf file at location:-

/etc/apache2/sites-available/amazonaws.com.conf

Content:-


ServerName ec2-52-20-211-238.compute-1.amazonaws.com

# logs configuration
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

WSGIDaemonProcess apple threads=5
WSGIScriptAlias /apple /var/www/apple/apple.wsgi
Alias /apple/static/ /var/www/apple/static/

Order allow,deny
Allow from all

WSGIDaemonProcess banana threads=5
WSGIScriptAlias /banana /var/www/banana/banana.wsgi
Alias /banana/static/ /var/www/banana/static/

Order allow,deny
Allow from all

Enable the above file which we created

sudo a2ensite amazonaws.com
sudo a2dissite 000-default