How to install multiple gancio instances on the same server
first published: 2024-03-25
last updated: 2024-03-25
Table of Contents

Gancio is an excellent shared calendar that federates using ActivityPub. It uses relatively few resources. I hosted a gancio calendar on a small VPS and wanted to host a few more instances for different purposes. I used these steps to install multiple instances of gancio alongside one another on the same VPS to save costs. These instructions can be iterated to run multiple instances on the same server. Updating all the instances at once is also easy.

Before you start

This guide assumes you have already installed one instance of gancio using the instructions for installing gancio on Debian. This won't work if you installed gancio using Docker.

It is also assumed that you have already procured a new domian/subdomain for your second gancio instance, and that you have properly configured the DNS for that domain to point to the server.

I use gancio-2 for the internal name of the second gancio installation here, but you can use a more informative name.

Log into your server as a user with sudo privileges.

Add a user

For security reasons, we'll keep each instance of gancio running under a different, unprivileged user. Create a new gancio-2 user with an accompanying new home folder at /opt/gancio-2 using the following command:

sudo adduser --group --system --shell /bin/false --home /opt/gancio-2 gancio-2

If you look in /opt/ you'll see two folders now, one gancio from your original installation and one gancio-2 for this new installation:

ls /opt/ -la

Create new config file

If you try to just initialize gancio in the new directory now, it will fail because the default port for gancio is already in use. Instead we'll copy the config file from our original instance and modify it manually for use by the new gancio-2 instance.

Copy the config file from the original gancio instance to the new gancio-2 directory:

sudo cp /opt/gancio/config.json /opt/gancio-2/config.json

Use nano, or your editor of choice, to edit the new config.json file:

sudo nano /opt/gancio-2/config.json

This is a copy of the config file for your original gancio instance, so it must be modified to work for the new gancio-2 instance.

Edit the "baseurl" and "hostname" appropriately to the url of your new gancio-2 instance.

Change all the paths /opt/gancio/ to /opt/gancio-2 in the "user_locale" "log_path" "storage" and "upload_path" lines.

Change the port number. gancio's default port is 13120 (nice) but this port is being used by the original gancio instance. I suggest changing it to 13121 for your gancio-2 instance.

Save the config file and exit your editor (control-O and control-X if using nano)

Change the ownership of the file to the new gancio-2 user:

sudo chown gancio-2:gancio-2 /opt/gancio-2/config.json

Initialize new gancio and create admin user

We'll initialize the new gancio-2 instance. Navigate to the new gancio-2 directory:

cd /opt/gancio-2

And run:

sudo -H -u gancio-2 bash -c 'gancio'

Let it run for a sec until the output stops, then control-c to kill it. Look at the output and it should confirm that everything is working.

Now manually create the admin user using gancio's CLI interface:

sudo -H -u gancio-2 bash -c 'gancio users create admin --admin'

And generate the admin user's password:

sudo -H -u gancio-2 bash -c gancio users reset-password admin

The password for the admin user will be spit out in the command line output. Cpy it to your password manager!

Modify nginx

Make a copy of the gancio nginx file for the new gancio-2 instance:

sudo cp /etc/nginx/sites-available/gancio /etc/nginx/sites-availabe/gancio-2

Now edit the new config file with nano or your editor of choice:

nano /etc/nginc/sites-available/gancio-2

Go through the file and change every occurrence of the domain name for the original gancio to the new domain name you are using for gancio-2.

This will be the server_name line, and the ssl-certificate lines.

We'll set up the cert soon so these certificate lines will work.

Now, look for the proxy_pass line. This is telling nginx where to send the traffic internally. It will be proxy_pass http://127.0.0.1:13120; and you should change the port number to the port your gancio-2 instance is running on internally (which you just set in the config file, eg 13121).

Once that's done, you can activate the site by creating the link for nginx:

ln -s /etc/nginx/sites-available/gancio-2 /etc/nginx/sites-enabled/

Get certificate with certbot

This is an easy way to get the certificate for the new domain using certbot.

Stop nginx (just for a sec):

sudo systemctl stop nginx

Use certbot in standalone mode to get the new cert:

sudo certbot certonly -d domain-for-new-gancio-2.com --standalone

If the cert was sucessfully acquired, restart nginx:

sudo systemctl start nginx

New systemd service

We'll create a new systemd service for gancio-2. Copy the service file for the original gancio instance:

sudo cp /etc/systemd/system/gancio.service /etc/systemd/system/gancio-2.service

And now edit the new service file:

sudo nano /etc/systemd/system/gancio-2.service

Change the User= to the new gancio-2 user and the WorkingDirectory= to the new /opt/gancio-2 directory.

Now reload systemd and enable the new service:

sudo systemctl daemon-reload

sudo systemctl enable gancio-2

sudo systemctl start gancio-2

Your new gancio site should be up!

Updating

gancio is installed globally using yarn, so updating gancio you just follow the official instructions:

https://gancio.org/install/debian#upgrade

This will update gancio server-wide, so all your instances will ne upgraded. Remember to backup each one individually before performing upgrades!!

The only catch is you have to restart each systemd service after upgrading:

sudo systemctl restart gancio

sudo systemctl restart gancio-2

path: index / articles / How to install multiple gancio instances on the same server