Python 3.5, Flask, Apache2, Mod_WSGI3 on Ubuntu 16.04

  1. Apache:
sudo apt-get update
sudo apt-get install apache2
python3 -V
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
alias python=python3.5
source ~/.bashrc
sudo apt-get install libapache2-mod-wsgi-py3sudo a2enmod wsgi
sudo apt-get update
sudo apt-get -y install python3-pip
alias pip=pip3
source ~/.bashrc
sudo pip install virtualenv
mkdir /www/var/directory/of/your/project
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
sudo nano /www/var/directory/of/project/project.wsgi#!/usr/bin/python
activate_this = '/var/www/FlaskApp/FlaskApp/venv/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))

import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")

from FlaskApp import app as application
<VirtualHost *:80>
ServerName server.com
WSGIDaemonProcess server_app threads=5
WSGIScriptAlias / /var/www/server.com/server/server_app.wsgi
DocumentRoot /var/www/server.com/server
<Directory /var/www/server.com/server>
WSGIProcessGroup server_app
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
sudo chown :www-data ~/myproject
sudo systemctl restart apache2
git init
git add .
git remote add origin 'url/to/repo'
git pull origin master
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache
sudo certbot --apache

--

--

Product Manager, Software Engineer, Problem Solver https://ethansteininger.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store