How to install Kimai on Ubuntu Server Latest

Kimai is a free and open-source time-tracking solution that records time spent on tasks and projects. In this tutorial, we will show you how to install Kimai on Ubuntu Server Latest.

Prerequisites

Before starting the installation process, ensure that:

  • Ubuntu Server is up-to-date.
  • A sudo non-root user with sudo privileges is created.

Step 1: Add PHP Repository

Kimai requires PHP 7.3 or higher. By default, Ubuntu Server’s repository only provides PHP 7.2. To install PHP 7.3, we'll add a third-party PPA repository.

Run the following commands to add the repository:

sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php

You should now see the following output:

Output:
Press [ENTER] to continue or Ctrl-c to cancel adding it.

gpg: keyring `/tmp/tmpdzpjbmnk/secring.gpg' created
gpg: keyring `/tmp/tmpdzpjbmnk/pubring.gpg' created
gpg: keyring `/etc/apt/trusted.gpg.d/php.gpg' created
gpg: key FDE2A1DBE23314F24FB2DBBDBC79C324596CA751: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg:               imported: 1 (RSA: 1)
OK

After adding the PPA, run the following command to install PHP 7.3:

sudo apt-get update
sudo apt-get install php7.3 php7.3-common php7.3-cli php7.3-fpm -y

Step 2: Install a Web Server

Kimai is a web-based application that requires a web server. In this tutorial, we'll use Apache as our web server.

Run the following command to install Apache:

sudo apt-get install apache2 -y

Step 3: Install MariaDB

sudo apt-get install mariadb-server mariadb-client -y

Once the installation is complete, run the following command to secure your MariaDB installation:

sudo mysql_secure_installation

To connect to MariaDB, you can run the following command:

sudo mysql -u root -p

Step 4: Create a database and user

To create a new database and user, follow the steps below:

  • Run the following command to log in to MariaDB:

    sudo mysql -u root -p
    
  • Create a new database for Kimai:

    CREATE DATABASE kimai;
    
  • Create a new user for Kimai and grant privileges to the newly created database:

    GRANT ALL ON kimai.* TO 'kimaiuser'@'localhost' IDENTIFIED BY 'password';
    

    Replace kimaiuser and password with your desired username and password.

  • Flush the privileges so that changes take effect:

    FLUSH PRIVILEGES;
    

Step 5: Download and Install Kimai

To download and install Kimai, follow the steps below:

  • Move to the /var/www/html directory:

    cd /var/www/html
    
  • Download the latest version of Kimai using the wget command:

    sudo wget https://github.com/kimai/kimai/releases/download/1.14.3/kimai-1.14.3.zip
    
  • Unzip the downloaded file:

    sudo apt-get install unzip -y
    sudo unzip kimai-1.14.3.zip
    
  • Rename the Kimai directory:

    sudo mv kimai-1.14.3 kimai
    
  • Set the ownership and permissions:

    sudo chown -R www-data:www-data /var/www/html/kimai
    sudo chmod -R 755 /var/www/html/kimai
    

Step 6: Configure Apache

To configure Apache for Kimai, follow the steps below:

  • Create a new Apache Configuration file for Kimai:

    sudo nano /etc/apache2/sites-available/kimai.conf
    
  • Add the following content to the file:

    <VirtualHost *:80>
      ServerName your_domain_or_IP_address
      ServerAlias www.your_domain_or_IP_address
      DocumentRoot /var/www/html/kimai
      <Directory /var/www/html/kimai>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
      </Directory>
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

    Replace your_domain_or_IP_address with either your domain name or IP address.

  • Enable the new configuration file:

    sudo a2ensite kimai.conf
    
  • Restart Apache to apply the changes:

    sudo systemctl restart apache2
    

Step 7: Access Kimai

After completing all the steps, you can now access your Kimai installation by opening a web browser and navigating to http://your_domain_or_IP_address/kimai.

Conclusion

Congratulations! You have successfully installed Kimai on Ubuntu Server Latest. You can now track your time and improve your project management.