logo
Jiff Slater
🤔 About
✍️ Contact
📚Knowledge
14 Jun 2021
 

Setting up Kanboard for local project management
13 May 2021

I’ve used Trello quite frequently in the past to manage my work items but wanted to move to a self-hosted version that didn’t data mine my every action or offer to integrate with various other services and companies that distract me from the work.  I came across Kanboard which is an open-source selfhosted kanboard software. In the installation instructions Docker was recommended but I opted to use the default server software that came with Debian.

Here’s how I did it.

Installing and configuring Apache, Postgresql, and PHP

First, we’ll configure the LAPP stack.

We’ll install the services and related PHP extensions.
# apt install apache2 php7.3 php-pgsql libapache2-mod-php
# apt install php-common php-xml php-gd php-mbstring php-json php-common php-zip php-fpm

Check that Apache2 started succesfully.  You should be able to view the normal configuration at http://localhost.
# systemctl status apache2

Next, we’ll enable PHP-FPM to have a separate user for each web site. FPM is the process manager for PHP.

Before we get started we’ll need to create a separate, isolated user for FPM.
# adduser --no-create-home --uid 5000 --disabled-password fpm-kanban

Start by creating a new pool.
# cd /etc/php/7.3/fpm/
# vim pool.d/kanban.conf
; Kanban pool
[kanban]
user = fpm-kanban
group = fpm-kanban
listen.owner = www-data
listen.group = www-data
listen = /run/php/php7.3-fpm-kanban.sock
pm.max_children = 100
pm = ondemand

Enable proxy and FPM support in Apache. Restart Apache afterwards and make sure FPM is running.
# a2enconf php7.3-fpm
# a2enmod proxy
# a2enmod proxy_fcgi
# systemctl restart apache2
# systemctl restart php7.3-fpm

Edit the php.ini configuration and turn off allow_url_fopen to reduce the attack surface of Kanboard.
# vim /etc/php/7.3/fpm/php.ini
allow_url_fopen = Off

Extracting and starting Kanboard

Configure the permissions for /var/www.
# chown -R root:www-data /var/www

Make a directory for kanboard. Apache will access the directory with www-data permissions but will send PHP connections to PHP-FPM which will run the scripts under the fpm-kanban user.
# mkdir /var/www/kanboard
# chown -R www-data:www-data /var/www/kanboard

In the Apache configuration directory create a new site.
# cd /etc/apache2
# a2dissite 000-default.conf
# touch ./sites-available/001-kanboard.conf
# vim !$

<VirtualHost *:80>
ServerName kanban.topology.aves
ServerAdmin webmaster@localhost
ErrorLog ${APACHE_LOG_DIR}/kanboard_error.log
CustomLog ${APACHE_LOG_DIR}/kanboard_access.log combined
DocumentRoot /var/www/kanboard
<Directory /var/www/kanboard>
Options -Indexes
AllowOverride All
Require all granted
</Directory>

<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.3-fpm-kanban.sock|fcgi://localhost"
</FilesMatch>

</VirtualHost>

Then we’ll test that the new site is working.

# cp /var/www/html/index.html /var/www/kanboard/
# chown www-data: /var/www/kanboard/index.html
# a2ensite 001-kanboard.conf
# systemctl reload apache2

Add the relevant information to your DNS resolver. I’m using Unbound.  This will redirect all subdomains under hostname.tld to hostname.tld.  Take note of the IP address used.
server:
local-zone: "hostname.tld" redirect
local-data: "hostname.tld 86400 IN A 192.168.1.1"

Visit the site and make sure it’s presented correctly at http://kanboard.hostname.tld

Next, we’ll test that PHP is working as intended by creating a sample PHP file to make sure the configuration is working.

echo '<!--?php phpinfo() ?-->' > /var/www/kanboard/index.php &&

Navigate again http://kanboard.hostname.tld and you should see the PHP debug information.

Next we’ll create a database in Postgresql to store the data. First make sure the database is online.
# systemctl status postgresql
# su -l postgres
# psql
# > create database kanboard;
# > create user kanban with login password 'kpassword';
# > \du # checks if user has been created
# > grant all privileges on database kanboard to kanban;
# > \l # lists the databases

Finally, we’ll extract Kanboard and set up the databases.

Download the latest and extract to the right directory.
# wget https://github.com/kanboard/kanboard/archive/refs/tags/v1.2.19.tar.gz
# tar xzf v1.2.19.tar.gz --strip-components=1 -C ./
# chown -R www-data: ./

Finally, configure database access for Kanboard in the config.php file.
# mv /var/www/kanboard/config_default.php /var/www/kanboard/config.php
# vim /var/www/kanboard/config.php

define('DB_DRIVER', 'postgres');

// Mysql parameters
define('DB_USERNAME', 'kanban');
define('DB_PASSWORD', 'kpassword');
define('DB_HOSTNAME', 'localhost');
define('DB_NAME', 'kanboard');

Now, navigate to http://kanban.hostname.tld and login with the default credentials of admin/admin

I’ll write another post at a later date explaining how I use Kanboard to manage my day-to-days! Enjoy!