The thing about Flask and Apache

In the building of, I eventually had to make a decision as to how I plan on hosting this web app.

Many platforms offer an easy mechanism for hosting a Flask app, such as Heroku and Google App Engine, but alas, those choices were not for me.

In the pursuit of understanding the intricacies of hosting, I decided to host the app on my VM using Apache, but all was not well.

It’s astounding the amount of different solutions presented online for this problem, and how few of them seem to work for me. Here I will describe my WSGI file and Apache config file for those who may be in the same position as me.

Instances of YOURAPP must be replaced with, obviously, your app!

<Virtualhost *:80>
	ServerAlias YOURAPP

	WSGIDaemonProcess YOURAPP user=YOU group=YOU threads=5 home=/PATH/TO/YOURAPP/

	<Directory /PATH/TO/YOUR/APP>
		WSGIProcessGroup YOURAPP
		WSGIApplicationGroup %{GLOBAL}
		WSGIScriptReloading On
		Order deny,allow
		Allow from all

The WSGI file, while simple, isn’t well described in most articles. This worked for me.

import sys


from YOURAPP import app as application

When that’s all said and done, enable your site, and reboot apache!

sudo a2ensite YOURAPP
sudo service apache2 restart

If you have any questions feel free to hit me an email with your problem!.