How to Create a Calendar Server With Baikal

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

requirements

Before installing Baikal, have the following resources ready:

  • A machine that can be accessed from outside your home network: This can either be a home server with ports open or a dedicated VPS that you are currently renting.
  • A domain name that points to your computer: I will use the name “yetanotherbaikalserver.xyz” for this tutorial.
  • Root access to your computer: This will install the utilities and programs necessary for Baikal to work.

Keeping these factors in mind, this tutorial will only focus on installing Baikal on a DigitalOcean Debian 11 VPS.

Install Baikal Linux 03 Digitalocean Droplet Summary 1

Install Baikal dependencies

First, create a separate user account on your computer to ensure that errors and errors during the process do 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 a new user

When you’re done, switch to that new user by running it 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 installation dependencies

Configure the server’s firewall

Configuring your computer’s firewall is necessary to ensure that your server blocks all unnecessary requests to it. To set this up, run the following commands:

sudo ufw allow 80
sudo ufw allow 443

The above commands only open ports 80 and 443 for external connection and close all network ports in the device.

Install Baikal Linux 06 Enable server firewall

Setting up Nginx for Lake Baikal

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

First, create a site configuration file under /etc/nginx/sites-available:

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

From there, write a server{} block within this new configuration file. The following is 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 for connections on port 80 for the hostname “yetanotherbaikalserver.xyz”. Once a client connects, the web server redirects that 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.

Sourcing and unpacking Lake Baikal

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

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

Then use wget to pull the latest binary from 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 here, install the web application by unpacking its binary archive with the following command:

sudo unzip ./baikal-0.9.2.zip
Install Baikal Linux 09 Unzip the binary archive

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

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, either using Let’s Encrypt or installing one manually via OpenSSL. In this case, I’m using Let’s Encrypt’s certbot utility.

Run the following command to install a Let’s Encrypt certificate:

certbot --nginx yetanotherbaikalserver.xyz

Completion of the Baikal setup

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

Once you get there, Baikal will redirect you to its admin installation page where you will be asked for a number of server-specific options to set for your instance.

First enter the time zone of your computer. If you are using a VPS, provide the time zone for that VPS.

Install Baikal Linux 11 default settings

Since my VPS is located in Singapore, I choose “Asia/Singapore”.

Install Baikal Linux 12 set time zone

Next, select the features 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. For this to work, your server must be able to send SMTP messages over TLS. I leave this field blank to disable sending emails.

Install Baikal Linux 14 Remove email address

Next, choose the authentication format for your instance. In most cases, the digest format should work out of the box. You must also provide a password for the administrator account. After that you can click on “Save Changes”.

Install Baikal Linux 15 authentication method

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

Install Baikal Linux 16 default database settings

Adding the first Baikal user

With Baikal running, you can now create your first user by going back 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 create 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

Connect Thunderbird to Baikal

Now that you have a Baikal user account, you can associate it with any scheduler that supports CalDAV and CardDAV, such as B.Thunderbird.

To use Baikal with Thunderbird, click the “Calendar” option on the email client home page.

Install Baikal Linux 19 Choose Calendar Thunderbird

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

Install Baikal Linux 20 Link Calendar To Network

If Thunderbird asks for your Baikal account username and URL, enter those details and click Find Calendar. Enter the address of your server followed by “/dav.php” as the URL.

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 to use.

frequently asked Questions

Systemctl reports that Nginx “could not bind”.

No! The “Failed to Bind” 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 computer. You can determine which program is using this resource by running this command: netstat -tulpn | grep -e :80 -e :443.

Once you know what program is causing the error, run it apt remove or 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 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 specific 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 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.

Photo credit: Unsplash and Saber All changes and screenshots from Ramces Red

Is this article useful?

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Leave a Reply

Your email address will not be published. Required fields are marked *