How to create a calendar server with Baikal

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

Preconditions

Before installing Baikal, prepare the following resources:

  • A machine accessible from outside your home network: This can be either a home server with open ports or a dedicated VPS that you currently rent.
  • A domain name that points to your machine: I will use the name “yetanotherbaikalserver.xyz” for this tutorial.
  • Root access to your machine: it is about installing the utilities and programs necessary for the operation of Baikal.

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

Installation of Baikal dependencies

Start by creating a separate user account on your machine to ensure that errors and errors during the process will not affect the whole system:

sudo useradd -s /bin/bash -d /home/baikal -m -G sudo baikal
sudo passwd baikal
Install Baikal Linux 04 Create a new user

Once done, switch to this new user by running su baikal. From there, you can now install Baikal 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 Setup Dependencies

Server firewall configuration

Configuring your machine’s firewall is necessary to ensure that your server will block all unnecessary requests to it. To configure it, run the following set of commands:

sudo ufw allow 80
sudo ufw allow 443

The commands above will simply open ports 80 and 443 for external connection and close all network ports on the machine.

Install Baikal Linux 06 Enable Server Firewall

Configuring Nginx for Baikal

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

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

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

From there, write a server{} block inside this new configuration file. Here’s a basic setup that should work right away:

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 listens on all connections to port 80 for the hostname “yetanotherbaikalserver.xyz”. Once a client connects, the web server redirects that connection to the Baikal root directory, where Nginx then opens a UNIX socket for all .php files, allowing them to run as a web application.

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 extract the latest binary version of Baikal:

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 there, 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

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

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

Restart Nginx and install 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 perform 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 using Let’s Encrypt or installing one manually via 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

Finalization of the Baikal configuration

To complete the setup process, open your web browser and access the website through your domain name. In my case, I go to “yetanotherbaikalserver.xyz”.

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

To get started, enter your machine’s time zone. If you use a VPS, indicate the time zone of this VPS.

Install Baikal Linux 11 Defaults

As my VPS is in Singapore, I select “Asia/Singapore”.

Install Baikal Linux 12 Set time zone

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

Install Baikal Linux 13 Install New Features

You also have the option of providing an email address for your instance. For this to work, your server must be able to send SMTP messages over TLS. I leave this field empty to disable the sending of e-mails.

Install Baikal Linux 14 Remove email address

Next, select the authentication format for your instance. In most cases, the Digest format should work right away. You must also provide a password for the administrator account. After that, you can tap on “Save Changes”.

Install Baikal Linux 15 authentication method

Finally, Baikal will ask you for your instance’s database settings. In most cases, you do not need to change the settings on this page. Press “Save Changes” again to complete the installation.

Install Baikal Linux 16 Default Database Settings

Added first Baikal user

With Baikal running, you can now create your first user by returning to the admin panel and selecting “Users and Resources”.

Install Baikal Linux 17 Select the Users tab

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

Install Baikal Linux 18 New User Details

Connecting Thunderbird to 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 on the “Calendar” option on the home page of the mail client.

Install Baikal Linux 19 Select Thunderbird Calendar

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

Install Baikal Linux 20 Link Calendar To Network

When Thunderbird asks for your Baikal account username and URL, fill in those details and press “Search Calendars”. For the URL, indicate the address of your server followed by “/dav.php”.

Install Baikal Linux 21 Thunderbird Server Details

Once the client gets all the calendar files from 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 to use.

Frequently Asked Questions

Systemctl reports that Nginx “failed to bind”.

Nope! The “bind failure” error occurs whenever a program fails to take control of a specific network port. In this case, Nginx has a conflict on ports 80 or 443 with an existing service on your machine. You can identify the program that is using 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 Where systemctl disable to stop the program.

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

My webserver still shows the Debian homepage after setting up Baikal. How can I fix this?

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

I can’t sync my calendar and the website reports a “DOM error”.

No. A “DOM Error” indicates that the PHP backend of your Baikal server is missing an XML module. To resolve this problem, 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 Saber All edits and screenshots by Ramces Red

Was this article helpful?

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Comments are closed.