Python Playground Part 2: Deploying Flask app on Ubuntu (nginx, uwsgi, supervisor, git)
14 Sep 2012
This is a followup on my previous post on building and getting up and running small online image placeholder generator service - https://noimageyet.com.
This post will list steps to set up a Flask app in Ubuntu Linux server 12.04 using nginx, uWSGI and supervisord. On top of that I will provide installation scripts and deployment scheme using Git SCM.
This post (and service deployement in live) would not be possible without these awesome resources:
 Conrad Kramer’s “Getting a Flask website up and running in Ubuntu”
 Conrad Kramer’s “Deploy a website using git in Ubuntu”
 Linode StackScript: shazow’s stack (nginx+uwsgi+postgresql+more)
Installing Python stack
NoImageYet also requires Python Imaging Library, which depends on certain native libs. Here it goes:
Installing Git, Supervisord and uWSGI
Creating Deploy / App user
You might want to change password from
password to something more applicable ;)
Auto-magic deploy script
The script below is derived from .
Script summary: scipt creates folder layout, configures NGINX site, updates supervisod config and setups Git repository with post-receive hook to perform re-deploy on push magic.
Script usage / Deploying
- Login as deploy user, e.g.
su - deploy
- Executing the script.
Parameters: app name (
theservice) and service domain name (
Please follow the script instructions. When pushing please note: the script assumes folder layout is
theservice.py exports Flask application as
- When application code has been pushed to server (following script recomendations) you should resolce app’s dependecies and do proper app’s configuration (db connections, etc ..)
We are done. Your service should be available at http://youdomain.com and http://www.youdomain.com.
Deploy part should be as easy as sample below
If you've found typos or errors, please
suggest a correction
edit on github