Serving Flask with nginx

Installing Common Python Tools for Deployment
apt-get install -y python python-dev python-distribute python-pip
apt-get install nginx

Installing The Web Application and Its Dependencies
Download and install Flask and uwsgi using pip

pip install virtualenv
mkdir /var/www/ && cd /var/www/
virtualenv -p /usr/bin/python venv
source venv/bin/activate
pip install uwsgi
pip install flask

rm /etc/nginx/conf.d/default

vim /etc/nginx/conf.d/ngstones

server {
listen 80;
charset utf-8;
client_max_body_size 75M;

location / { try_files $uri @ngstones; }
location @ngstones {
include uwsgi_params;
uwsgi_pass unix:/var/www/;

vim /var/www/

#application's base folder
base = /var/www/

#python module to import
app = hello
module = %(app)

home = %(base)/venv
pythonpath = %(base)

#socket file’s location
socket = /var/www/

#permissions for the socket file
chmod-socket = 666

#the variable that holds a flask application inside the module imported at line #6
callable = app

#location of log files
logto = /var/log/uwsgi/%n.log

vim /var/www/
from flask import Flask
app = Flask(__name__)
def hello():
return “Hello!”
if __name__ == “__main__”:

Restart Nginx to load new config file
service nginx restart
cd /var/www/
uwsgi --ini /var/www/

Finally update your DNS and you are good to go!


How to Install Docker on Ubuntu 14.04 LTS

Docker is an open-source project that automates the deployment of applications inside software containers, by providing an additional layer of abstraction and automation of operating-system-level virtualization on Linux. Docker uses resource isolation features of the Linux kernel such as cgroups and kernel namespaces to allow independent “containers” to run within a single Linux instance, avoiding the overhead of starting virtual machines.

Here some tips for installing docker on an Ubuntu 14.04 LTS.

Let’s install docker :
apt-get -y install

Let’s fix link and path :
ln -sf /usr/bin/ /usr/local/bin/docker
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/

And finally configure docker to start when the server boot :
update-rc.d defaults

Of course we search container that contains ubuntu by search token
docker search ubuntu

And we install it
docker pull ubuntu