
Introduction
Cal.com is a self-hosted open-source appointment scheduling application. It is an alternative to Calendly and allows you to efficiently schedule meetings, appointments, and link external services such as Google Calendar, Zoom through a simple to use web dashboard.
In this guide, you will install self-hosted Cal.com on a Ubuntu 20.04 server.
Prerequisites
- Deploy a Ubuntu 20.04 server on Vultr.
- Setup a subdomain to the server.
- Access the server.
- Install PostgreSQL.
- Install Nginx.
Setup the Cal Database
Switch to the postgres user account.
# su postgresOpen the PostgreSQL console.
$ psqlCreate a new Cal Database.
postgres=# CREATE DATABASE caldb;Create a new database user with a strong password.
postgres=# CREATE USER admin WITH PASSWORD 'strong password';Give the new user full rights to the database.
postgres=# GRANT ALL PRIVILEGES ON DATABASE caldb TO admin;Quit the PostgreSQL console.
postgres=# exitExit the Postgre user account.
EXITInstall NodeJS
Setup the NodeJS version 14 repository.
# curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -Install NodeJS.
# apt install nodejs -yInstall Yarn.
# npm install --global yarnInstall Cal
Clone the Cal.com Github repository.
# git clone https://github.com/calcom/cal.com.gitMove the cal.com directory to /opt/. Or if you prefer another system-wide location, like `/usr/local/', adjust the steps below for your location.
# mv cal.com/ /opt/Switch to /apps/web/ in the project directory.
# cd /opt/cal.com/apps/web/Create a new .env configuration file from the .env.example template in the cal.com directory.
# cp ../../.env.example .envRun Yarn to Install Cal dependencies.
# yarnEnable Cal.com to run in production mode.
# yarn buildConfigure Nginx as a reverse proxy
Using your favorite editor, create and edit a new Nginx server configuration file.
# nano /etc/nginx/conf.d/cal.confPaste the following Nginx configurations:
server {
listen [::]:80;
listen 80;
server_name cal.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
}Replace
cal.example.comwith your actual subdomain.
Save the file.
Test the current Nginx configuration.
# nginx -tRestart Nginx
# systemctl restart nginxConfigure Cal as a system service.
Create a new systemd service file.
# nano /etc/systemd/system/cal.servicePaste the following contents:
[Unit]
Description=Self Hosted Cal.com
After=network.target
[Service]
Type=simple
User=example
ExecStart=yarn start
WorkingDirectory=/opt/cal.com/apps/web
Restart=on-failure
[Install]
WantedBy=multi-user.targetReplace
examplewith an existing user account on your server.
Save the file.
Enable the service.
# systemctl enable cal.serviceRestart the Systemd daemon.
# systemctl daemon-reloadConfigure Firewall
Temporarily allow Prisma to run on Port 5555.
# ufw allow 5555/tcpThen, allow HTTP traffic on port 80.
# ufw allow 80/tcpAllow HTTPS on port 443.
# ufw allow 443/tcpRestart the firewall.
# ufw reloadSetup Cal.com
Using Bcrypt, generate an encrypted password.
Then, install the necessary Prisma database schema using the following command.
# npx prisma migrate deployStart Prisma Studio.
# npx prisma studioUsing a web browser, load Prisma Studio by visiting your Server IP on port 5555.
http://Server-IP:5555Select User from the model list. Then, click Add Record to set up a new by filling in the username, name, email, encrypted password fields, scroll through and enter {} in the metadata field.
Next, stop Prisma, and start Cal with the following command.
# systemctl start calNow, visit your configured sub-domain to start Cal
http://cal.example.comLog in with your username, and password (plain) to start using the self-hosted Cal web application.
Conclusion
Congratulations! You have successfully installed self-hosted Cal on Ubuntu 20.04. To integrate external services, and configure your web dashboard, visit the Cal.com documentation page.