How to Install Radicale Calendar (CalDAV and CardDAV) on Ubuntu 20.04

Radicale is a free and open-source CalDAV (Calendars, to-do lists) and CardDav (contacts) server. It aims to be a small and lightweight (CalDAV and CardDav) server application, yet powerful and works out-of-the-box. Radicale allows you to shares calendars and contact lists through CalDAV, CardDAV, and HTTPS. And most importantly, it can be secure through TLS connection and authentication. Also, it works with many CalDAV and CardDAV clients such as gnome-calendar, evolution, Mozilla thunderbird, DAVx (for android), etc.

Radicale comes with a simple configuration, and it's easy to configure and install. Radicale is written in Python, it runs on operating systems like Linux, BSD, macOS, and Windows.

In this tutorial, you will learn how to install and configure Radicale on Ubuntu 20.04.

Prerequisites

  • An Ubuntu 20.04. Ensure packages and repositories are updated.
  • A root user or user with the root privileges. This will be used for installing new packages and editing system configuration.

Installing Passlib and Bcrypt Library

In the beginning, you will be installing some packages dependencies for the radicale installation. You will be installing the python-pip, python-passlib module, then installing the python bcrypt module from the PyPI (python repository).

1. Execute the following apt command to install python-pip and python-passlib module to the Ubuntu system.

sudo apt install python3-pip python3-passlib

Type 'Y' and press 'Enter' to install all of those packages.

Install Python Pip and Passlib Library

2. If the installation is complete, run the pip command below for installing the Python bcrypt module.

sudo pip3 install bcrypt

Now you will see the following output.

Install Bcrypt library

Installing and Configuring Radicale

By default, the radicale packages are available at the Ubuntu repository.

1. Execute the apt command below to install radicale on the Ubuntu system.

sudo apt install radicale

Type 'Y' and press 'Enter' to install radicale packages.

Install Radicale Calendar on Ubuntu

2. After the installation is complete, you will be editing the default radicale configuration that is available at '/etc/radicale/config'.

Edit the radical configuration using the nano command below.

sudo nano /etc/radicale/config

3. At the [server] section, change the default configuration using the following configuration.

[server]

host = 127.0.0.1:5232
max_connections = 20
max_content_length = 100000000
timout = 30

The radicale server will be running only on the local IP address because we will put the Apache web server as a reverse proxy at the front of it.

4. Next, comment on the SSL configuration as below, because the SSL encryption will be done through the Apache reverse proxy.

# SSL flag, enable HTTPS protocol
#ssl = False

# SSL certificate path
#certificate = /etc/ssl/certs/ssl-cert-snakeoil.pem

# SSL private key
#key = /etc/ssl/private/ssl-cert-snakeoil.key

5. After that, move to the '[auth]' section and change the default configuration as follows.

[auth]
type = htpasswd
htpasswd_filename = /etc/radicale/users
htpasswd_encryption = bcrypt

The authentication type we're using is 'htpasswd' with the strong encryption 'bcrypt', and a list of users will be stored at the '/etc/radicale/users' file.

6. Next, at the bottom configuration you will see the '[storage]' section. Change the configuration as below to enable the radicale storage backend.

[storage]
type = multifilysystem
filesystem_folder = /var/lib/radicale/collections
filesystem_locking = True

The default storage backend for radicale is 'multifilesystem', and all user's data are available at the '/var/lib/radicale/collections' directory.

Now press 'Ctrl+x' and type 'y', then press the 'Enter' button to save and exit.

Generate Users for Radicale

At this stage, the configuration of radicale is completed. And for now, you will be creating a new user and password for radicale, which is can be generated using the 'htpasswd' command (part of the 'apache2-utils' package).

1. Execute the apt command below for installing the 'apache2-utils' package.

sudo apt install apache2-utils

Type 'Y' and press 'Enter' to continue the installation.

Install Apache utils package

2. next, generate a new user (for this example is user 'johndoe') and password by running the htpasswd command below.

sudo htpasswd -B -c /etc/radicale/users johndoe

Now type and repeat the password for user 'johndoe'.

Important options you must know:

  • -B option - this will force to use the strong encryption 'bcrypt', not the default 'md5'.
  • -c option - The password file you want to create. Username and passwords are available on that file.

To add another user, just run the command on top and change the username with your own.

Optionally, check the generated password file '/etc/radicale/users' using the cat command as below.

cat /etc/radicale/users

Generate htpasswd users and password

3. After generating the user and password file, enable the radicale service to start automatically at boot.

sudo systemctl enable radicale

4. Now start the radicale service and check the service status by executing the following command.

sudo systemctl start radicale
sudo systemctl status radicale

If your radicale service is active and running, you will see a similar output as below. Otherwise, you will see the radicale service status as 'failed' at the bottom of the log messages.

Start and check radicale service status

Setup Apache as a Reverse Proxy for Radicale

At this stage, you will be installing and configuring the Apache as a reverse proxy for the radicale.

1. Install Apache packages by executing the apt command below.

sudo apt install apache2

Now type 'Y' and press 'Enter' to continue the installation.

Install Apache Web Server

2. After the installation is complete, execute the following command to enable some proxy module for Apache and enable the mod_ssl module.

sudo a2enmod proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html ssl

3. Now change the working directory to '/etc/apache2/sites-available' and create a new virtual host configuration 'radicale.conf'.

cd /etc/apache2/sites-available/
sudo nano radicale.conf

Copy and paste the following configuration and make sure to change the domain name with your own.

<VirtualHost *:80>
        
    ServerName cal.domain-name.io
    ServerAdmin [email protected]

    ErrorLog ${APACHE_LOG_DIR}/cal-dmain-name.io.error.log
    CustomLog ${APACHE_LOG_DIR}/cal-dmain-name.io.access.log combined

    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    RewriteEngine On
    RewriteRule ^/radicale$ /radicale/ [R,L]

    <Location "/radicale/">
        AuthType     Basic
        AuthName     "Radicale - Password Required"
        AuthUserFile "/etc/radicale/users"
        Require      valid-user

        ProxyPass        http://localhost:5232/ retry=0
        ProxyPassReverse http://localhost:5232/
        RequestHeader    set X-Script-Name /radicale
        RequestHeader    set X-Remote-User expr=%{REMOTE_USER}
    </Location>

    <Location />
        Order allow,deny
        Allow from all
    </Location>

</VirtualHost>

Save the configuration by pressing the 'Ctrl+x' and type 'y', then press 'Enter'.

Using this configuration, the radicale will be available at the domain path 'domain.com/radicale', not at the root path of the domain name.

4. Next, execute the following command to activate the virtual host configuration 'radicale.conf'.

sudo a2ensite radicale.conf

5. After that, verify the Apache configuration and make sure there is no error, then restart the Apache service to apply the new virtual host configuration.

sudo apachectl configtest
sudo systemctl restart apache2

If your Apache configuration is correct, you will see the message 'Syntax OK' after running the 'apachectl' command. And below is the similar output you will get.

Setting Up Apache Virtual Host for Radicale

Generate SSL Letsencrypt

For this stage, you will be securing the radicale installation using the SSL Letsencrypt.

1. Execute the following command to install the certbot and certbot-apache plugin.

sudo apt install certbot python-certbot-apache

2. After the installation is complete, generate a new SSL Letsencrtypt for the radicale domain name using the certbot command below.

sudo certbot --apache -d domain-name.io -d www.domain-name.io

And you will be asked some questions below.

  • An email address: when the SSL certificate expires, you will be noticed to this email.
  • Letsencrypt TOS (Terms of Service): type 'A' to agree.
  • Sharing email with EFF: you can choose 'N' for no.
  • Automatically redirect HTTP to HTTPS: choose number '2' to enable auto-redirect.

Once the process is complete, you will see the SSL certificates are available at the '/etc/letsencrypt/live/domain.com' directory. And the Apache virtual host has changed with additional configuration from letsencrypt.

Verify Installation

Open your web browser and type the radicale URL installation at the address bar.

https://cal.domain-name.io/radicale/

Now you will be asked for the user and password for the Apache basic authentication.

Radicale Apache Basic Authentication

Type your user and password, then click the 'Sign in' button.

And you will get the Radicale login page as below.

Radicale login page

Type your user and password for Radicale and click the 'Next' button.

Once you've logged in, click the link 'Create a new address book or calendar'.

Create new calendar

Change the title, description, type, and color with your own, then click the 'Create' button.

Create new calendar

Now you will be redirected to the radicale user dashboard as below.

Radicale user dashboard

Conclusion

Congratulations! Now you've successfully installed Radicale on Ubuntu 20.04 Server. For the next stage, you can connect to your new radicale server securely using the CalDAV/CardDAV clients from your computer or smartphone android.

Share this page:

6 Comment(s)