Quick install guide

There are a lot of ways to deploy it. This guide provide one simple way.

Requirements

Believe writen in python with Django framework. Also it is need Redis database for cache and tasks.
Application need these libraries to run: django, django-rq, djangorestframework, django-filter, redis, pytz, pillow or PIL, psycopg2. For more details look requirements.txt.
You can use any django supported database server. It is officially works with PostgreSQL, MySQL, Oracle and SQLite. For more look here

Note

App tested only with ubuntu 12.04, python 2.7 / 3.2, postgres 9 and uwsgi & nginx.

Database driver and image library

There is two ways. First install them from ubuntu package library. Or install from source. The second is more preferred.

From packages

sudo apt-get install python-pip python-psycopg2 python-imaging
sudo pip install django-rq django-tastypie==0.9.15 django>=1.5 fabric pytz redis

From source

sudo apt-get install python-dev python-pip
sudo apt-get install libjpeg-dev libfreetype6-dev zlib1g-dev
sudo apt-get install libpq-dev
sudo pip install -r requirements.txt

Redis database

For task queue bviewer use redis database. In default repositories version is too old. So it is needed to use ppa, rwky/redis for example.
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:rwky/redis
sudo apt-get update
sudo apt-get install redis

Setup application

Copy sample setting file, and edit it. At least it is need to set cache, storage path and allowed hosts.
cp bviewer/settings/sample.py bviewer/settings/local.py
vim bviewer/settings/local.py
After run command to create tables in database. On syncing you will be prompt to create admin user. Then collect all static files from apps to one directory where web server can server it.
python manage.py syncdb
fab static

WSGI server

To run application as daemon we install uwsgi.
sudo apt-get install uwsgi uwsgi-plugin-python
Than copy sample config and change paths in it according to yours installation folder.
sudo cp docs/files/uwsgi.ini /etc/uwsgi/apps-available/uwsgi.ini
sudo vim /etc/uwsgi/apps-available/uwsgi.ini
sudo ln -s /etc/uwsgi/apps-available/uwsgi.ini /etc/uwsgi/apps-enabled/uwsgi.ini
uwsgi.ini file content:
[uwsgi]
uid = believe
gid = believe
plugins = python
socket = /var/run/believe.sock
chown-socket = believe:www-data
master = true
processes = 8
python-path = /home/believe/viewer
chdir = /home/believe
module = bviewer.wsgi
env = LANG=ru_RU.UTF-8
attach-daemon = python /home/believe/viewer/manage.py rqworker default low
attach-daemon = python /home/believe/viewer/manage.py rqworker default
disable-logging = true
After restart usgi service.
sudo service uwsgi restart

Note

For background tasks, such as image processing by default starts 2 workers. With default and low queue.

Note

For python 3 use uwsgi-plugin-python3 and replace in uwsgi.ini python to python32

Web server

To run web server we need install nginx.
sudo apt-get install nginx
Than copy sample config. Change paths according to yours installation folder, change domains.
sudo cp docs/files/nginx.conf /etc/nginx/apps-available/believe.conf
sudo vim /etc/nginx/apps-available/believe.conf
sudo ln -s /etc/nginx/apps-available/believe.conf /etc/nginx/apps-enabled/believe.conf
nginx.conf file content:
server {
    listen 80 default;

    server_name believe.com www.believe.com;

    charset utf-8;

    keepalive_timeout 150;
    client_max_body_size 1024m;

    #access_log /var/log/nginx/believe.access.log;
    error_log /var/log/nginx/believe.error.log;

    location / {
        include uwsgi_params;
        uwsgi_pass unix:///var/run/believe.sock;
    }

    location /static {
        access_log off;
        expires 7d;
        gzip_static on;
        alias /home/believe/viewer/static;
    }

    location /favicon.ico {
        access_log off;
        expires max;
        alias /home/believe/viewer/bviewer/static/favicon.ico;
    }

    location /robots.txt {
        alias /home/believe/viewer/bviewer/static/robots.txt;
    }

    location /protected {
        internal;
        alias /home/believe/viewer/cache;
    }
}
After restart nginx service.
sudo service nginx restart