I am trying to deploy a Flask project on Ubuntu 16 server (Apache2). In this project, I am using Python3 libraries. So I want to set Flask to use Python 3 on the server. But I am really having a terrible time. Here is what I am doing:
sudo apt-get install apache2
sudo apt-get update
sudo apt-get install libapache2-mod-wsgi-py3 # I think that is how you install wsgi for python3
sudo apt-get install python-flask
sudo apt-get upgrade
my project conf: /etc/apache2/sites-available/project.conf
<VirtualHost *:80>
ServerName 52.25.54.241 #my IP
ServerAdmin admin@mywebsite.com
WSGIScriptAlias / /var/www/FlaskApps/FlaskApps.wsgi
<Directory /var/www/FlaskApps/project/>
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/FlaskApps/project/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 finally: /var/www/FlaskApps/FlaskApps.wsgi
#! /usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApps/project/")
# home points to the home.py file
from home import app as application
application.secret_key = "somesecretsessionkey"
NOTE: When I install wsgi like this:
sudo apt-get install libapache2-mod-wsgi
it works, but it uses python2. and When I install wsgi 3. It does not work and it says no module called flask. So how can I set flask to use python3 by default?
I read this question: Getting Flask to use Python3 (Apache/mod_wsgi) but it didn't help me. It is not clear for me because they are using virtualenv.