Installation of Taiga.io on Centos 7

(Technology, Tutorials)

Update: 02.12.2017: This post is no longer accurate on the installation process.

In this tutorial, we will install Taiga.io project management system on CentOS 7 operating system.  The official taiga instructions are for Ubuntu and certain changes are required for the same process to work in CentOS.  In this tutorial I will use my own setup as an example.  I will install Taiga using a subdomain so I can access the installation through https://project.tomkarho.com.  I also use only https via let’s encrypt ssl certificate.  Nginx will serve as a proxy to whatever is running taiga.

1. Installing dependencies

Our first step is to install some dependencies.  Due to different packaging CentOS and Ubuntu have different names (and sometimes bundled software packages) for these dependencies so in this step will be shown not only what packages to install but also their Ubuntu equivelant.

Ubuntu CentOS
build-essential gcc gcc-c++ make openssl-devel
 binutils-doc  binutils
 autoconf  autoconf
 flex  flex
 bison  bison
 libjpeg-dev libjpeg-devel
 libfreetype6-dev  freetype-devel
 zlib1g-dev  zlib-devel
libzmq3-dev perl-ZMQ-LibZMQ3
 libgdbm-dev  gdbm-devel
 libncurses5-dev  ncurses-devel
 automake  automake
 libtool  libtool
libffi-dev  libffi-devel
 curl  curl
 git  git
 tmux tmux
 gettext  gettext

And the full command to install these packages:

sudo yum -y install gcc gcc-c++ make openssl-devel binutils autoconf flex bison libjpeg-devel freetype-devel zlib-devel perl-ZMQ-LibZMQ3 gdbm-devel ncurses-devel automake libtool libffi-devel curl git tmux gettext

2. Setting up database

Taiga uses postgresql as a database engine.  CentOS 7 at the time of writing this still contains old version of postgresql (9.2 while taiga requires at least 9.3) and such we will have to install postgresql from another repository than CentOS regulars.

First we will add the rpm for newer postgresql version.

sudo rpm -Uvh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm

Then we will install postgresql.

sudo yum -y install postgresql95 postgresqp95-devel postgresql95-contrib postgresql95-docs postgresql95-server

Then we will initialize the database.

sudo /usr/pgsql-9.5/bin/postgresql95-setup initdb

And start the server.

sudo systemctl enable postgresql-9.5
sudo systemctl start postgresql-9.5

Next we will setup the initial user and database.

sudo -u postgres createuser taiga
sudo -u postgres createdb taiga -O taiga

3. Installing python

Taiga.io is comprised of two components: backend written with python and frontend written in angular.  Let’s install python next.

sudo yum -y install python35u python35u-pip python35u-devel python-devel python-pip python-virtualenvwrapper libxml2-devel libxslt-devel

Note: in order for virtualenvwrapper specific variables and functions to be available you must restart your ssh session to server.

4. Backend code

Now to the actual taiga code installation.  First we will install the backend code.  In order to keep the installation in specific place we will create a seperate system user taiga.  Let’s create taiga user and login as taiga.  Then we will download and configure the backend code.

sudo useradd -m -g users -s /bin/bash taiga
sudo su - taiga

Also since virtualenv is a little on the old kind, we will update that.

sudo pip install --upgrade virtualenv

Note: The following commands are ran as taiga users in taiga home.

git clone https://github.com/taigaio/taiga-back.git taiga-back
cd taiga-back
git checkout stable

Then we will create a new virtual environment to keep python packages in check.

mkvirtualenv -p /usr/bin/python3.5 taiga

At this point we need to add some symlinks.  Since we are using non-standard version of postgres, certain names are no longer valid.  One of those is pg_config.  We can circumvent the absence of pg_config by adding a symlink to the postgresql 9.5 version.

sudo ln -s /usr/pgsql-9.5/bin/pg_config /usr/bin/pg_config

Next let’s install the rquired python packages with pip.

pip install -r requirements.txt

If your system does not have enough RAM then the installation will fail fod lxml.  To circumvent this, we will add temporary swap space to be used during compilation.

sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
swapon -s

Run the install again and grap a cold one. This will take a while.

After the requirements are installed (and there are no errors), lets run the database migration files.

python manage.py migrate --noinput
python manage.py loaddata initial_user
python manage.py loaddata initial_project_templates
python manage.py loaddata initial_role
python manage.py compilemessages
python manage.py collectstatic --noinput

If you want sample data then also run:

python manage.py sample_data

Next we will put the following content to ~/taiga-back/settings/local.py:

from .common import *

MEDIA_URL = "https://project.tomkarho.com/media/"
STATIC_URL = "https://project.tomkarho.com/static/"
ADMIN_MEDIA_PREFIX = "https://project.tomkarho.com/static/admin/"
SITES["front"]["scheme"] = "https"
SITES["front"]["domain"] = "project.tomkarho.com"

SECRET_KEY = "theveryultratopsecretkey"

DEBUG = False
TEMPLATE_DEBUG = False
PUBLIC_REGISTER_ENABLED = True

DEFAULT_FROM_EMAIL = "taiga@tomkarho.com"
SERVER_EMAIL = DEFAULT_FROM_EMAIL

# Uncomment and populate with proper connection parameters
# for enable email sending. EMAIL_HOST_USER should end by @domain.tld
#EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
#EMAIL_USE_TLS = False
#EMAIL_HOST = "localhost"
#EMAIL_HOST_USER = ""
#EMAIL_HOST_PASSWORD = ""
#EMAIL_PORT = 25

# Uncomment and populate with proper connection parameters
# for enable github login/singin.
#GITHUB_API_CLIENT_ID = "yourgithubclientid"
#GITHUB_API_CLIENT_SECRET = "yourgithubclientsecret"

Substitute project.tomkarho.com with your desired url and if you want to use http, replace https with http.

Next, lets verify that our backend installation works as expected.  Start the backend in development mode.

python manage.py runserver

By doing wget http://localhost:8000/api/v1 we should get an index.html file with some content in it.

After verification, close the development environment.

Taiga.back is installed.  Halfway there!

4. Frontend code

Frontend code for taiga is downloaded in similar fashion to backend.

cd ~
git clone https://github.com/taigaio/taiga-front-dist.git taiga-front-dist
cd taiga-front-dist
git checkout stable

Copy example config file and edit.

cp ~/taiga-front-dist/dist/conf.example.json ~/taiga-front-dist/dist/conf.json
nano ~/taiga-front-dist/dist/conf.json

The config should look something like this:

{
    "api": "https://project.tomkarho.com/api/v1/",
    "eventsUrl": "ws://example.com/events",
    "debug": "true",
    "publicRegisterEnabled": true,
    "feedbackEnabled": true,
    "privacyPolicyUrl": null,
    "termsOfServiceUrl": null,
    "maxUploadFileSize": null,
    "contribPlugins": []
}

Once again, substitute project.tomkarho.com with your own url.

Thats it for frontend.  Now all we need to do is to serve both sets of code via nginx.

5. Serving the code with NGINX

First, let’s install circus and gunicorn.  These two will manage the python installation allowing it to be served via nginx.

cd
git clone https://github.com/circus-tent/circus.git circus
mkdir -p ~/conf/
nano~/conf/circus.ini

Pass the following:

[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
statsd = true

[watcher:taiga]
working_dir = /home/taiga/taiga-back
cmd = gunicorn
args = -w 3 -t 60 --pythonpath=. -b 127.0.0.1:8001 taiga.wsgi
uid = taiga
numprocesses = 1
autostart = true
send_hup = true
stdout_stream.class = FileStream
stdout_stream.filename = /home/taiga/logs/gunicorn.stdout.log
stdout_stream.max_bytes = 10485760
stdout_stream.backup_count = 4
stderr_stream.class = FileStream
stderr_stream.filename = /home/taiga/logs/gunicorn.stderr.log
stderr_stream.max_bytes = 10485760
stderr_stream.backup_count = 4

[env:taiga]
PATH = /home/taiga/.virtualenvs/taiga/bin:$PATH
TERM=rxvt-256color
SHELL=/bin/bash
USER=taiga
LANG=en_US.UTF-8
HOME=/home/taiga
PYTHONPATH=/home/taiga/.virtualenvs/taiga/lib/python3.5/site-packages

Next, let’s start circus.  In centos we will have to create a .service file for systemd to recognize circus.

cat > /usr/lib/systemd/system/circus.service << EOF

[Unit]
Description=circus


[Service]
ExecStart=/usr/local/bin/circusd /home/taiga/conf/circus.ini
EOF
ln -s '/usr/lib/systemd/system/circus.service' '/etc/systemd/system/circus.service'
mkdir -p /home/taiga/logs touch /home/taiga/logs/gunicorn.stdout.log touch /home/taiga/logs/gunicorn.stderr.log  cd /home/taiga/circus/ python3.5 setup.py install ln -s /opt/python3.5/bin/circusd /usr/local/bin/circusd systemctl start circus.service

Next, let’s setup nginx.  This tutorial assumes that nginx is already installed.  Here is my config file for reference:

server {
 listen 80;
 listen [::]:80;
 server_name project.tomkarho.com;

return 301 https://$host$request_uri;
}
server {
 listen 443 ssl;
 listen [::]:443;
 server_name project.tomkarho.com;
 root /srv/sites/project.tomkarho.com/html;

# Load configuration files for the default server block.
 include /etc/nginx/default.d/*.conf;

ssl_certificate /etc/letsencrypt/live/project.tomkarho.com/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/project.tomkarho.com/privkey.pem;

access_log /srv/sites/project.tomkarho.com/logs/access.log;
 error_log /srv/sites/project.tomkarho.com/logs/error.log;

include partials/ssl-params.conf;

#TAIGA SPECIFIC BEGINS HERE

# Frontend
 location / {
 root /home/taiga/taiga-front-dist/dist/;
 try_files $uri $uri/ /index.html;
 }

# Backend
 location /api {
 proxy_set_header Host $http_host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Scheme $scheme;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass http://127.0.0.1:8001/api;
 proxy_redirect off;
 }

# Django admin access (/admin/)
 location /admin {
 proxy_set_header Host $http_host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Scheme $scheme;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass http://127.0.0.1:8001$request_uri;
 proxy_redirect off;
 }

# Static files
 location /static {
 alias /home/taiga/taiga-back/static;
 }

# Media files
 location /media {
 alias /home/taiga/taiga-back/media;
 }
}

After writing and enabling the config file, restart nginx.

systemctl restart nginx

Finally, let’s give nginx access to our taiga installation:

chown -R taiga:nginx /home/taiga/
chmod o+x /home/taiga/

There.  Now we are done.  You should be able to login to your taiga installation with credentials admin:123123.

 

Leave a Reply

Your email address will not be published. Required fields are marked *