Thursday, December 26, 2024
Google search engine
HomeUncategorisedInstall Kimai web-based time tracking application

Install Kimai web-based time tracking application

Kimai is a free, open source and online time-tracking software designed for small businesses and freelancers. It tracks work time and prints out a summary of your activities on demand. Yearly, monthly, daily, by customer, by project. The platform supports an unlimited amount of users and timesheet entries, so you can handle all of your teams or departments in one easy-to-use installation. And do not forget that Kimai is built with modern technologies such as Symfony, Bootstrap, RESTful API, Doctrine, AdminLTE, Webpack, ES6 and others.

Whether you are a freelancer, a small organization or a company with hundreds of employees, we shall setup Kimai and get to see the benefits that it will bring to you.

Features of Kimai Time Tracker

The following are some of the features you will immediately begin to enjoy from Kimai

  • Creation of invoices from your timesheets within your browser
  • Tracking of your working hours
  • An unlimited amount of users and timesheet entries
  • Tracking times using your mobile device
  • Translated into multiple languages and missing translations can be added easily, using the open translation standard Xliff.
  • Free and Open Source
  • Easy-to-use installation

Kimai’s Pre-requisites

Kimai’s simplicity on requires the following for it to run in your server

  • Web server (Apache or Nginx)
  • PHP
  • Composer
  • MySQL Database server

Once everything is set, let’s visit our Ubuntu 20.04 server and bid welcome this new Kimai visitor by following the following steps:

Step 1: Update and prepare your server

We are going to start on a clean slate and hence we shall update our server to get the latest software and patches. Apart from that, we shall install the tools we shall need in the next steps. Run the following commands to get our server updated and install necessary packages like git.

##On Debian/Ubuntu
sudo apt update -y
sudo apt install git curl vim 

##On RHEL-based Systems
sudo yum makecache
sudo yum install git curl vim pcre2

Step 2: Install and Setup database

We are going to use MariaDB for this setup. Fortunately, we have detailed guides already to get MariaDB/MySQL installed. Check out

After you have the database installed, the next step is to create a database and user for Kimai. Let us, therefore, go ahead and get this done as shown below. You are free to name your database and user differently and ensure you use a safe password.

$ mysql -u root -p
Enter password: (Enter root Password>
...
MariaDB [(none)]>

Create a user and database using the commands:

CREATE DATABASE kimai_database;
CREATE USER 'userkimai'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON kimai_database . * TO 'userkimai'@'localhost';
FLUSH PRIVILEGES;
exit;

You may need to replace StrongPassword with your own desired password for the database.

Step 3: Install and Configure Web server and PHP

In order to get Kimai pages served, there has to be a web server. Here, you have the freedom of either picking Apache or Nginx. We shall use Nginx for this guide. Additionally, Kimai requires PHP and therefore we will have to set it up as well. Note that the version of PHP required is PHP >=8.1.

We have a complete guide that covers the installation of PHP:

After that is done, install all required PHP extensions as follows

##On Debian/Ubuntu
sudo apt install php-intl php-gd php-curl php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath

##On RHEL-Based Systems
sudo yum install php-intl php-gd php-curl php-cli php-fpm php-json php-common php-mysqli php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath

Verify the PHP version:

$ php -v
PHP 8.2.10 (cli) (built: Aug 29 2023 15:31:38) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.10, Copyright (c) Zend Technologies

Once installed, you need to make the modifications. Opne the PHP-FPM file for editing:

##On Debian/Ubuntu
sudo vim /etc/php/*/fpm/php.ini

##On RHEL-Based Systems
sudo vim /etc/php.ini

Open up your php-fpm ini file and add/edit the details shown below. They include Timezone, and memory limit settings. Add your date.timezone and change memory_limit to 512MB.

...
memory_limit = 512M

[Date]
date.timezone = Africa/Nairobi

On Rhel-based systems, you need to configure PHP-FPM to use Nginx as shown:

$ sudo vim /etc/php-fpm.d/www.conf
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

Save the file and restart PHP-FPM:

sudo systemctl restart php-fpm

Install composer

Composer is a brilliant tool that installs PHP dependencies that a project requires. We shall use its amazing features to install the dependencies that Flarum requires. Run the following commands to setup composer 1 that Kimai’s files are compatible with real quick.

To get the latest Composer version, visit the official Github release page

cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --version=2.6.2 --install-dir=/usr/local/bin --filename=composer

Verify the installation:

$ composer -V
Composer version 2.6.2 2023-09-03 14:09:15

You can export your path:

$ vim ~/.bashrc
export PATH=$PATH:/usr/local/bin

Source the profile:

source ~/.bashrc

Step 4: Fetch Kimai’s files from Git and configure Nginx

We shall create a new directory (root) that Kimai’s files will reside as well as read and served by the webserver of our choice. You can create a different one according to your needs and design.

cd /var/www/html/
sudo git clone https://github.com/kimai/kimai.git
cd kimai/

Install all the required components with the command:

sudo composer install --no-dev --optimize-autoloader
##OR
sudo su
composer install --no-dev --optimize-autoloader

Configure the database connection in the .env file by setting the username, password and database we configured in Step 2.

$ sudo vim /var/www/html/kimai/.env
......
##Edit the following
DATABASE_URL=mysql://userkimai:[email protected]:3306/kimai_database

And then run the Kimai installer:

cd /var/www/html/kimai
sudo bin/console kimai:install -n

You should see something similar to the following during Kimai’s installation.

kimai install terminal

Then create your first user as follows. You will be prompted for a password, make sure it is more than 8 characters.

sudo bin/console kimai:user:create username [email protected] ROLE_SUPER_ADMIN

Generate Self-signed SSL/TLS certificates

Once Kimai installer is done, we will generate SSL/TLS certificates for the Nginx SSL connection and create a Nginx configuration file to define Kimai’s settings. This is just to make things a bit secure.

sudo mkdir -p /etc/ssl/private
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/kimai-selfsigned.key -out /etc/ssl/certs/kimai-selfsigned.crt

Proceed as shown below:

.....
##Enter Required details##
Generating a RSA private key
.........................................+++++
................................................+++++
writing new private key to '/etc/ssl/private/kimai-selfsigned.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:KE
State or Province Name (full name) [Some-State]:Nairobi
Locality Name (eg, city) []:Nairobi
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Computingforgeeks
Organizational Unit Name (eg, section) []:Infra
Common Name (e.g. server FQDN or YOUR name) []:geeksforgeeks.org
Email Address []:[email protected]

Once it is done we will next generate Deffie-Hellman group as follows. It will take some time to complete.

sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048

Install and Configure Nginx

We need to ensure that Nginx has been installed and configured correctly. If you have Apache installed, disable it

##On Debian/Ubuntu
sudo systemctl stop apache2
sudo systemcl disable apache2

##On Rhel-based Systems
sudo systemctl stop httpd
sudo systemctl disable httpd

Now install Nginx:

##On Debian/Ubuntu
sudo apt install nginx -y 

##On Rhel-based Systems
sudo yum install nginx -y

We now have to make a few changes to the Nginx configuration defaults by adding the details we need to serve Kimai. Change into sites-enabled, back up the default file and create a new one with new configurations.

Then set the value of types_hash_max_size to 4096 in Nginx configuration file.

sudo sed -i 's/types_hash_max_size 2048/types_hash_max_size 4096/' /etc/nginx/nginx.conf

Create a virtual host file for Kimai

sudo vim /etc/nginx/conf.d/kimai.conf

Create a new file and add the details shown below. If you have an FQDN, replace example.com with it.

server {
    listen 80;
    server_name kimai.example.com;
    return 301 https://$host$request_uri;
}
server {
    listen 443 ssl;
    server_name kimai.example.com;

    root /var/www/html/kimai/public/;
    index index.php index.htm index.nginx-debian.html;

        ssl_certificate /etc/ssl/certs/kimai-selfsigned.crt;
    ssl_certificate_key /etc/ssl/private/kimai-selfsigned.key;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on; 
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
    ssl_ecdh_curve secp384r1;
    ssl_session_timeout  10m;
    ssl_session_cache shared:SSL:10m;
    resolver 8.8.8.8 valid=300s;
    resolver_timeout 5s; 
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";

    location ~ /\.ht {
        deny all;
    }
    location / {
                try_files $uri /index.php$is_args$args;
    }

        location ~ ^/index\.php(/|$) {
##On Debian-based
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
##On Rhel-based
#        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_index index.php;
        fastcgi_read_timeout 240;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        }
    location ~ \.php$ {
        return 404;
    }
 }

In the file, replace your server name and the path to your PHP-FPM sock accordingly.

Change Kimai’s files permissions

In order for Nginx to read Kimai’s files, we have to grant it the rights and the right permissions. Issue the commands below to get that done.

##On Debian/Ubuntu
sudo chown -R www-data:www-data /var/www/html/kimai
sudo chmod -R 755 /var/www/html/kimai
sudo chmod -R g+rw /var/www/html/kimai/var/

##On Rhel-based:
sudo chown -R nginx:nginx /var/www/html/kimai
sudo chmod -R 755 /var/www/html/kimai
sudo chmod -R g+rw /var/www/html/kimai/var/

Restart the services:

##On Debian/Ubuntu
sudo systemctl restart nginx php*-fpm

##On Rhel-based:
sudo systemctl restart nginx php-fpm

Once we are done, we should finally allow ports 80 and 443 on the firewall

##On UFW
sudo ufw allow 80,443/tcp

##On Firewalld
sudo firewall-cmd --add-port={80,443}/tcp --permanent
sudo firewall-cmd --reload

Step 5: Access Kimai Web Interface

To complete setting up Kimai, point your browser to the IP or domain name of the webserver serving the files. https://[ip-or-domain-name]. You should be redirected to https and get a login page like below.

Install Kimai web based time tracking application 10

Enter the details we set in Step 4

kimai login dashboard

Step 6: Multi-tenancy

Teams allow you to organize your users in groups and limit access to customers and projects. A team consists of a Teamlead and an unlimited amount of team members. The teamlead has access to all contents and timesheets of the team. Every content object can be linked to an arbitrary number of teams.

Permission details

With multi-tenancy in Kimai, we first have a look at the available user roles and how their permission work when using teams (this only applies when you use the default permission configuration):

  • System-Admin: can see and manage all content and use all administrative functions.
  • Administrator: can see and manage all content, but access to system specific settings and contents (like users) are limited.
  • Teamlead: can see all un-privileged contents and all contents assigned to his teams. Team specific contents can be managed for all teams where this user is the Teamlead.
  • User: can see all un-privileged contents and all contents assigned to his teams.

Creating users

Navigate to the “Users” Tab on the Kimai dashboard and click on it. After that, click on the + to create a new user.

kimai dashboard create user 1

Enter the details as shown below then click “Save” below the page

kimai dashboard create user 2

After saving it, a new page will be presented where you can add “Roles” and the rest. Enter the right roles for the user. Do this for as many users as you have.

kimai dashboard create user 3 create roles

Creating a team

Team creation is limited to the user roles System-Admin and Administrator. Navigate to the “Teams” Tab on the Kimai dashboard and click on it. Click on the + located at the top right to create a new team.

kimai dashboard teams 1 1

Enter the details of the team you are creating. You can add the members you would wish to be part of this team.

kimai dashboard teams 2
kimai dashboard teams 3

Later you can add Projects, Activites, Timesheets as well as plugins.

Conclusion

If you are serious about your projects, then it is prudent to have everything your team is handling on track. You need to know where every minute of productive time is being spend on and that will guarantee quality and timely products. Kimai is a good place to keep everything in sync and orderly. Give it a try and experience the benefits it proffers. Find out more about Kimai from its Official Website as well as its GitHub page. Finally, we appreciate your continued support and for spending time on the blog. You can enjoy other guides shared below.

RELATED ARTICLES

Most Popular

Recent Comments