How to Install Davis (CalDAV/CardDAV Server) on Ubuntu 24.04

Davis is a modern, open-source, self-hosted CalDAV/CardDAV server with a beautiful web interface. Perfect for managing shared calendars, staff shift scheduling, team availability, contacts, and syncing with phones, Outlook, Thunderbird, Apple Calendar, etc.

Install Required Packages (LAMP + Composer)

sudo apt update && sudo apt upgrade -y
sudo apt install -y apache2 mariadb-server \
    php php-cli php-mysql php-xml php-mbstring php-intl php-gd php-curl php-zip \
    composer git unzip curl

sudo a2enmod rewrite headers ssl
sudo systemctl restart apache2

Secure MariaDB and Set Root Password

sudo mysql_secure_installation

Create Database and User for Davis

sudo mysql -u root -pYour-Strong-Password <<EOF
DROP DATABASE IF EXISTS davis_db;
CREATE DATABASE davis_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'davis_user'@'localhost' IDENTIFIED BY 'Your-strong-password';
GRANT ALL PRIVILEGES ON davis_db.* TO 'davis_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
EOF

Replace "Your Strong Password' with the actual password/strong password

Download and Install Latest Davis

sudo rm -rf /var/www/davis
cd /var/www
sudo git clone https://github.com/tchapi/davis.git davis
cd davis
sudo composer install --no-dev --optimize-autoloader
sudo chown -R www-data:www-data /var/www/davis
sudo chmod -R 755 /var/www/davis

Configure Davis (.env.local)

cd /var/www/davis
sudo cp .env .env.local
sudo bash -c "cat > .env.local" <<EOF
APP_ENV=prod
APP_DEBUG=0
APP_SECRET=$(php -r "echo bin2hex(random_bytes(32)); echo PHP_EOL;")
DATABASE_URL="mysql://davis_user:Your-Strong-Password@127.0.0.1:3306/davis_db?charset=utf8mb4"
TRUSTED_HOSTS=^Your-IP-Address$
EOF

Replace "Your Strong Password' with the actual password/strong password

Run Symfony Setup & Database Migrations

sudo -u www-data composer dump-env prod
sudo -u www-data php bin/console cache:clear --env=prod
sudo -u www-data php bin/console doctrine:migrations:migrate --no-interaction --env=prod

Create Admin User

HASH=$(sudo -u www-data php bin/console security:hash-password Your-strong-password --env=prod | grep "Password hash" | cut -d ' ' -f4)
sudo mysql -u davis_user -pYour-strong-password davis_db -e "
INSERT INTO user (username, email, password, roles, enabled, created_at, updated_at, timezone)
VALUES ('admin', 'admin@yourcompany.com', '$HASH', '[\"ROLE_ADMIN\",\"ROLE_USER\"]', 1, NOW(), NOW(), 'UTC');
"

Replace "Your Strong Password' with the actual password/strong password

Configure Apache Virtual Host

sudo bash -c "cat > /etc/apache2/sites-available/davis.conf" <<EOF
<VirtualHost *:80>
    ServerName Your-IP-Address
    DocumentRoot /var/www/davis/public
    <Directory /var/www/davis/public>
        AllowOverride All
        Require all granted
    </Directory>
    RewriteEngine On
    RewriteRule ^\.well-known/carddav /dav/ [R=301,L]
    RewriteRule ^\.well-known/caldav  /dav/ [R=301,L]
</VirtualHost>
EOF

sudo a2ensite davis.conf
sudo a2dissite 000-default.conf 2>/dev/null || true
sudo systemctl restart apache2

Open Firewall Ports

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload

Access Davis Dashboard

Open your browser and go to:

http://Your-IP-Address

Login credentials: Username: admin Password: Your-strong-password

images

images

images

You will see the beautiful Davis dashboard!


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS