User Tools

Site Tools


adm:setting_up_zibawa

Setting Up Zibawa

Install Python, Postgres and Required development libraries

Zibawa runs on Python 3

sudo apt-get update
sudo apt-get install libpq-dev postgresql postgresql-contrib libsasl2-dev  libldap2-dev libssl-dev python3 python3-dev python3-venv

Setup Empty databases and users for Zibawa and Grafana

Change to postgres user

sudo su - postgres

As postgres user go into postgres shell to set up databases for zibawa and grafana and create user for each.

Important! Change the two passwords in the script below. Recommended: Use the same database and user names as script below. The user and password must coincide with those in settings.py within the zibawa project and also in grafana.ini file.

(The createDB permission is only necessary if we want to run tests via Django.)

psql
CREATE DATABASE zibawadb;
CREATE USER zibawauser WITH PASSWORD 'zibawapsw';
ALTER ROLE zibawauser SET client_encoding TO 'utf8';
ALTER ROLE zibawauser SET default_transaction_isolation TO 'read committed';
ALTER ROLE zibawauser SET timezone TO 'UTC';
ALTER USER zibawauser CREATEDB;
GRANT ALL PRIVILEGES ON DATABASE zibawadb TO zibawauser;

CREATE DATABASE grafana;
CREATE USER grafanauser WITH PASSWORD 'grafanazibawapsw';
ALTER ROLE grafanauser SET client_encoding TO 'utf8';
ALTER ROLE grafanauser SET default_transaction_isolation TO 'read committed';
ALTER ROLE grafanauser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE grafana TO grafanauser;

\q
exit

Copy the Zibawa Code to the Server

Recommended: use “zibawa” as user to minimize modifications to installation scripts.

sudo adduser zibawa
cd /home/zibawa
sudo git clone https://github.com/zibawa/zibawa

Updating with the latest code would in future be:

git pull origin master

Change ownership of all files to zibawa

sudo chown -R zibawa:zibawa /home/zibawa

Check ownership of files is zibawa

sudo ls -l /home/zibawa

Create Virtual Environment for Python3

su zibawa
mkdir /home/zibawa/virtualenv
cd /home/zibawa/virtualenv
python3 -m venv zib3
source zib3/bin/activate

(zib3)$

(zib3)$ which pip

Install Project Dependencies

pip install --upgrade wheel
pip install -r /home/zibawa/zibawa/requirements.txt

Create directory for logs

sudo mkdir /var/log/zibawa
sudo chmod 751 /var/log/zibawa
sudo chown -R zibawa:zibawa /var/log/zibawa

Edit settings.py

Edit settings-sample.py from the distribution and save as settings.py Settings.py should be in the zibawa directory below manage.py

nano /home/zibawa/zibawa/zibawa/settings.py
allowedHostschange to your server name
databasemake sure database, user and password are according to your installation

Setup the Postgres database

The following commands will set up the postgres database for Zibawa.

python manage.py migrate

Check Installation so far by running Django Tests

python manage.py test

If you try to run test server from the directory where you have loaded your files:

python /home/zibawa/zibawa/manage.py runserver 0.0.0.0:8000

The test server should start without error messages at this point. Any error messages at this point may indicate python dependencies that have not installed properly, or settings or passwords that have not been properly set in settings.py.

Create directory for static files

In settings.py a directory has been defined to serve static files from Zibawa. Django will automatically copy all its static files to this directory with the collectstatic command for manage.py.

We need to create this directory and ensure that the Nginx user has permissions to write to the directory.

sudo mkdir /var/www/html/zibawa/static
sudo chown -R www-data:www-data /var/www
sudo python /home/zibawa/zibawa/manage.py collectstatic

Create User Group "editor"

Login to the Zibawa Admin area

Click on Users>Groups

Add a new group 'editor'

Add permissions as shown:

Upgrading Zibawa

Make sure you have fully backed up your system. Move to your Zibawa home directory

cd /home/zibawa/zibawa
<code>

Change to zibawa user
<code>
su zibawa

Activate virtual environment

source /home/zibawa/environments/zib3/bin/activate 

Download latest code from Git repository

git pull origin master

Check the release notes to see if it is necessary to edit settings.py if there are any new requirements since your last version.

nano /home/zibawa/zibawa/zibawa/settings.py

Install any new python dependencies

pip install -r /home/zibawa/zibawa/requirements.txt

Migrate database (DONT make migrations)

python manage.py migrate

Run tests

python manage.py test

Restart Zibawa

sudo systemctl restart emperor.uwsgi.service
adm/setting_up_zibawa.txt · Last modified: 2017/04/20 09:03 by matt