How to Create a Calendar Server With Baikal

Install Baikal Linux 00 Featured Image

Baikal is a simple calendar software that allows you to synchronize CardDAV and CalDAV files online. Unlike Google Calendar, it synchronizes calendar files between different clients and devices seamlessly. The app also supports multi-user instances, which means that it is possible to use Baikal with other people and share calendar events as you do in Google Calendar. For example, you can host a personal Baikal server for your friends and family as well as colleagues.

Also read: 10 Calendar Apps That Make Great Google Calendar Alternatives

Prerequisites

Before you install Baikal, keep the following resources ready:

  • A machine accessible from outside your home network: this can either be a home server that has its ports open or a dedicated VPS that you are currently renting.
  • A domain name that points to your machine: I will be using the name “yetanotherbaikalserver.xyz” for this tutorial.
  • Root access to your machine: this is to install the utilities and programs that are needed for Baikal to work.

Considering these factors, this tutorial only focuses on installing Baikal on a Debian 11 VPS from DigitalOcean.

Install Baikal Linux 03 Digitalocean Droplet Summary 1

Installing Baikal’s Dependencies

Begin by creating a separate user account on your machine to make sure that any mistakes and errors during the process will not affect the entire system:

sudo useradd -s /bin/bash -d /home/baikal -m -G sudo baikal
sudo passwd baikal
Install Baikal Linux 04 Create New User

Once done, switch to this new user by running su baikal. From here, you can now install Baikal’s dependencies by running the following command:

sudo apt install php php7.4-fpm php7.4-xml php-sqlite3 sqlite3 nginx certbot python3-certbot-nginx iptables iptables-persistent ufw net-tools unzip
Install Baikal Linux 05 Install Dependencies

Also read: How to Sync CalDAV and CardDAV to Android

Configuring the Server’s Firewall

Configuring your machine’s firewall is required to ensure that your server will block any unnecessary requests to it. To set this up, run the following set of commands:

sudo ufw allow 80
sudo ufw allow 443

The above commands will just open the port 80 and 443 for external connection and close all the network ports in the machine.

Install Baikal Linux 06 Enable Server Firewall

Setting Up Nginx for Baikal

While it is possible to use a variety of webservers for Baikal, this section focuses on setting it up alongside Nginx.

To start, create a site configuration file under “/etc/nginx/sites-available”:

sudo nano/etc/nginx/sites-available/baikal
Install Baikal Linux 07 Create Nginx Config

From there, write a server{} block inside this new configuration file. The following is a basic setup that should work out of the box:

server {
  listen       80;
  server_name  yetanotherbaikalserver.xyz;
 
  root  /var/www/baikal/html;
  index index.php;
 
  rewrite ^/.well-known/caldav /dav.php redirect;
  rewrite ^/.well-known/carddav /dav.php redirect;
 
  charset utf-8;
 
  location ~ /(\.ht|Core|Specific|config) {
    deny all;
    return 404;
  }
 
  location ~ ^(.+\.php)(.*)$ {
    try_files $fastcgi_script_name =404;
    include        /etc/nginx/fastcgi_params;
    fastcgi_split_path_info  ^(.+\.php)(.*)$;
    fastcgi_pass   unix:/var/run/php/php-fpm.sock;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO        $fastcgi_path_info;
  }
}

The way it works is that Nginx is listening for any connections at port 80 for the hostname “yetanotherbaikalserver.xyz.” Once a client connects, the web server redirects this connection to Baikal’s root directory, where Nginx then opens a UNIX socket for all .php files, allowing them to run as a web application.

Also read: How to Show Lunar/Moon Phases in Google Calendar

Obtaining and Unpacking Baikal

To download and install Baikal on your machine, first create the root web directory and switch to it:

sudo mkdir -p /var/www/ && cd /var/www/

Then, use wget to pull Baikal’s latest binary release:

sudo wget https://github.com/sabre-io/Baikal/releases/download/0.9.2/baikal-0.9.2.zip
Install Baikal Linux 08 Download Binary Archive

From here, install the web application by unpacking its binary archive using the following command:

sudo unzip ./baikal-0.9.2.zip
Install Baikal Linux 09 Unzip Binary Archive

Lastly, make sure that Nginx can read and write to the root Baikal directory by running chown on the “baikal” folder:

sudo chown -R www-data:www-data ./baikal

Restarting Nginx and Installing SSL

You can now enable your Nginx configuration file by creating a symbolic link to “/etc/nginx/sites-enabled.” After that, you also need to reload Nginx to apply the new settings. Run the following commands to execute these two actions:

sudo ln -s /etc/nginx/sites-available/baikal /etc/nginx/sites-enabled
sudo systemctl restart nginx
Install Baikal Linux 10 Restart Nginx

Now, enable SSL for your server by either using Let’s Encrypt or installing one manually through OpenSSL. For this instance, I’m using the certbot utility from Let’s Encrypt.

To install a Let’s Encrypt certificate, run the following command:

certbot --nginx yetanotherbaikalserver.xyz

Also read: How to Create a Search Engine With SearXNG

Finalizing the Baikal Setup

To wrap up the setup process, open your web browser and access the website through your domain name. In my case, I’m going to “yetanotherbaikalserver.xyz.”

Once there, Baikal will redirect you to its admin installation page, where it will ask you for a number of server-specific options that you need to set for your instance.

To begin with, enter the timezone of your machine. If you are using a VPS, provide the timezone for that VPS.

Install Baikal Linux 11 Default Settings

Since my VPS is in Singapore, I’m selecting “Asia/Singapore.”

Install Baikal Linux 12 Set Timezone

Next, select the features that you want for your instance. Check both CalDAV and CardDAV if you want to enable both calendar and address book support for your server.

Install Baikal Linux 13 Install New Features

You also have the option to provide an email address for your instance. In order for this to work, your server must be able to send SMTP messages over TLS. I’m leaving this blank to disable email sending.

Install Baikal Linux 14 Remove Email Address

Next, select the authentication format for your instance. In most cases, the Digest format should work out of the box. You also need to provide a password for the administrator account. After that, you can press “Save changes.”

Install Baikal Linux 15 Authentication Method

Lastly, Baikal will ask you for the database settings of your instance. For the most part, you do not need to modify any settings on this page. Press “Save Changes” again to finish the installation.

Install Baikal Linux 16 Default Database Settings

Also read: How to Share Locations and Invite People to Events with Google Calendar

Adding the First Baikal User

With Baikal running, you can now create your first user by going back to the administrator panel and selecting “Users and resources.”

Install Baikal Linux 17 Select Users Tab

On the next screen, select “Add user” to bring up a simple creation page where you can enter the details for the new user. For example, I can create a new user for myself.

Install Baikal Linux 18 New User Details

Also read: How to Install Your Own Federated Twitter with Pleroma

Linking Thunderbird With Baikal

Now that you have a Baikal user account, you can link it to any scheduling program that supports CalDAV and CardDAV, such as Thunderbird.

To use Baikal with Thunderbird, click the “Calendar” option on the mail client’s Home page.

Install Baikal Linux 19 Select Calendar Thunderbird

This will bring up a small window where the client will ask you for the location of your calendar file. Select “On the Network” and click “Next” to proceed.

Install Baikal Linux 20 Link Calendar To Network

When Thunderbird asks you for the username of your Baikal account as well as its URL, fill in those details and press “Find Calendars.” For the URL, provide the address of your server followed by “/dav.php.”

Install Baikal Linux 21 Server Details Thunderbird

Once the client gets all the calendar files for your Baikal account, it will list them and ask you for their “Calendar Type.” Select “CalDAV” and click “Subscribe.”

Install Baikal Linux 22 Set Calendar Type

Your Baikal server is now ready for use.

Also read: 9 of the Best Email Clients for Linux

Frequently Asked Questions

Systemctl reports that Nginx "failed to bind."

No! The “failed to bind” error occurs whenever a program fails to take control of a specific network port. In this instance, Nginx is having a conflict on either ports 80 or 443 with an existing service in your machine. You can identify which program is taking up this resource by running this command: netstat -tulpn | grep -e :80 -e :443.

Once you know which program is causing the error, run apt remove or systemctl disable to stop the program.

For example, Apache is a common program that takes the same ports as Nginx. You can disable this in Debian by running the following command: sudo systemctl disable apache2.

My web server is still showing the Debian Welcome page after setting up Baikal. How do I fix this?

This issue is most likely due to conflicting Nginx configuration files. By default, Debian provides a basic Nginx setup that includes a configuration file in “/etc/nginx/sites-enabled.” You need to delete that particular file by running this command: sudo rm /etc/nginx/sites-enabled/default.

I can't synchronize my calendar and the website is reporting a "DOM Error."

No. A “DOM Error” indicates that the PHP backend for your Baikal server is missing an XML module. To fix this, either reinstall PHP or manually install the XML module. For example, you can run the following command to install the missing module in Debian: sudo apt install php7.4-xml.

Image credit: Unsplash and Sabre All alterations and screenshots by Ramces Red

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red
Ramces Red - Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.