Bottlepy + Nginx + Uwsgi + Python3 with Virtualenv on Debian

Bottle is my favorite micro web framework for  python.  It is well designed, allows quick prototyping and also developing web based applications.

My preferred web application stack is bottle + nginx + uwsgi + firebird + debian.

So this is my brief tutorial for this stack :

Install required packages :

Prepare web files directory structure for nginx :

Let’s create our virtualenv for our applications. I prefer placing my virtaulenvs in opt directory :

Time to activate our virtualenv and install bottle :

To create our simple demo application :

And code of our simple demo application :

Let’s check if everything is working so far :

If your output is similar to below output then everything is well so far. When you locate to http://localhost:8081, your browser should say “hello” to you.

Now we can safely deactivate our virtualenv,

and start nginx configuration, first we have to create a virtual host file for nginx :

content of the nginx virtualhost is :

to activate our virtualhost we symlink it to sites-enabled directory :

Now it is time to configure our uwsgi. First we create our uswgi appliaction configuration file :

bottledemo.ini content

and symlink to enabled applications :

last touches :

4 thoughts on “Bottlepy + Nginx + Uwsgi + Python3 with Virtualenv on Debian

  1. nginx fails to reload when I restart it, or stop start it. I have brand new ubuntu 14.04 and exactly fallowed your steps.

    My app did not start as local host i had to enter it’s internal IP does it have anything to do with it?

  2. Seems like I left “default” word in my second file that I made under /etc/nginx/sites-available, that’s why nginx was thinking that it has two default sites.

    Once I removed that, all semed to work. Thanks for the great tutorial, it’s in my bookmarks now!

Bir Cevap Yazın