HOWTO run a flask app under apache

In an effort to switch my php based web sites to python, here are the steps required to make a python based web app available under an apache server, using wsgi.

under /var/www/hello:

hello <-- folder with flask app hello/venv <-- virtualenv with all dependencies installed hello.wsgi <-- file with following contents:

activate_this = '/var/www/hello/hello/venv/bin/'
execfile(activate_this, dict(__file__=activate_this))
import sys
import logging

from hello import app as application

Howto generate a secret (from flask documentation):

python -c 'import os; print(os.urandom(16))'

And then in the apache site configuration the following will make the app active:

WSGIDaemonProcess flaskapp user=www-data group=www-data threads=5 home=/var/www/hello/hello
WSGIScriptAlias /hello /var/www/hello/hello.wsgi

WSGIProcessGroup flaskapp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Order deny,allow
Allow from all

Alias /hello/static /var/www/hello/hello/static

Order allow,deny
Allow from all

And that should make the site available under the path /hello