How to Install Baïkal on Arch Linux

Baïkal is a simple yet powerful open-source CalDAV and CardDAV server that provides synchronization capabilities for calendars and contacts. In this tutorial, we will show you how to install and configure Baïkal on an Arch Linux system.

Prerequisites

Before starting, make sure that you have a running Arch Linux system with root privileges.

Step 1: Install Required Dependencies

The first step is to install the required dependencies for Baïkal. Open your terminal and enter the following commands:

sudo pacman -S php php-fpm php-intl php-pgsql postgresql nginx

Step 2: Configure the PostgreSQL Database

Next, we need to configure the PostgreSQL database for Baïkal. Run the following commands to create a new PostgreSQL user and database:

sudo -iu postgres
createuser baikal
createdb -O baikal baikal
exit

Step 3: Download and Configure Baïkal

Now, let's download and configure Baïkal. In your terminal, enter the following commands:

cd /srv/http
sudo git clone https://github.com/sabre-io/Baikal.git baikal
sudo chown -R http:http baikal
cd baikal
sudo cp db/db.sqlite db/backup.db.sqlite
sudo cp Specific/Configuration/SQLite/db.sqlite db/db.sqlite
sudo chmod 775 db/db.sqlite
sudo cp Specific/Configuration/postgresql/pg.sql db/pg.sql
sudo nano db/pg.sql

In the editor, make the following changes:

CREATE DATABASE baikal;
\c baikal

Save and exit the file.

Next, we need to create a new configuration file for Baïkal. Run the following command:

sudo cp Specific/Configuration/postgresql/config.php config/config.php

Open the config file in your editor:

sudo nano config/config.php

Make the following changes:

'ADMIN_PASSWORD' => 'replace_with_your_admin_password',
'CALDAV_BACKEND' => 'PDO',
'PDO_BACKEND_DSN' => 'pgsql:host=localhost;port=5432;dbname=baikal',
'PDO_BACKEND_USERNAME' => 'baikal',
'PDO_BACKEND_PASSWORD' => 'replace_with_your_db_password',
'LOG_PATH' => '/tmp/baikal.log',

Save and exit the file.

Step 4: Configure Nginx

Finally, let's configure the Nginx web server for Baïkal. Run the following command to create a new server block:

sudo nano /etc/nginx/conf.d/baikal.conf

Add the following content:

server {
    listen 80;
    server_name your_domain.com;

    root /srv/http/baikal/Specific;

    error_log /var/log/nginx/baikal_error.log;
    access_log /var/log/nginx/baikal_access.log;

    location / {
        try_files $uri /db/sync${uri};
    }

    location /vendor/ {
        deny all;
        return 404;
    }

    location /app/ {
        deny all;
        return 404;
    }

    location ~ ^/(db|plugins|templates) {
        deny all;
        return 404;
    }

    location /card.php/ {
        include fastcgi.conf;
        fastcgi_param PHP_VALUE "auto_prepend_file=/srv/http/baikal/html/prepend.php";
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
    }

    location /cal.php/ {
        include fastcgi.conf;
        fastcgi_param PHP_VALUE "auto_prepend_file=/srv/http/baikal/html/prepend.php";
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
    }

    location /html/ {
        # This is required for PHP with PHP-FPM
        try_files $uri /html/search.php?$args;
    }

    location /db/ {
        # This is required for PHP with PHP-FPM
        try_files $uri =404;
    }
}

Save and exit the file.

Restart both PostgreSQL and PHP-FPM services:

sudo systemctl restart postgresql php-fpm

You can now start Nginx and enable automatic start on system boot:

sudo systemctl start nginx
sudo systemctl enable nginx

Step 5: Open Firewall Ports (Optional)

If you are using a firewall, you will need to open the following ports to allow traffic:

sudo firewall-cmd --add-port=80/tcp --permanent
sudo firewall-cmd --reload

Step 6: Access Baïkal

Baïkal is now installed and configured on your Arch Linux system. You can access it by visiting http://your_server_ip in your web browser.

Log in with the default admin account (username: admin, password: admin) and change the password as soon as possible.

Congratulations, you have successfully installed and configured Baïkal on an Arch Linux system!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!