How to Install Dendrite on FreeBSD Latest

Dendrite is an alternative Matrix homeserver written in Golang. It is lightweight and more performant compared to its predecessor Synapse. In this tutorial, we will learn how to install and configure Dendrite on FreeBSD Latest.

Prerequisites

Before continuing with this tutorial, make sure your server meets the following requirements:

Step 1: Installing Golang

Dendrite is built using the Go language, so we need to install the Go programming language on our system.

Enter the following command to download and extract the Go binary archive:

$ sudo fetch https://dl.google.com/go/go1.15.6.linux-amd64.tar.gz
$ sudo tar -C /usr/local -xzf go1.15.6.linux-amd64.tar.gz

Now, set the Go environment variables by editing the /etc/profile file:

$ sudo nano /etc/profile

Add the following lines to the end of the file:

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go

Save and close the file.

Reload the environment variables:

$ source /etc/profile

Verify the installation by running the following command:

$ go version

You should get the output like below:

go version go1.15.6 linux/amd64

Step 2: Install PostgreSQL

Dendrite requires a PostgreSQL database for managing user accounts and other data. Install PostgreSQL by running the following command:

$ sudo pkg install postgresql13-server postgresql13-client

After the installation is complete, enable the PostgreSQL service at boot time by running the following command:

$ sudo sysrc postgresql_enable="YES"

Start the PostgreSQL service:

$ sudo service postgresql initdb
$ sudo service postgresql start

Now, create a new PostgreSQL user and database for Dendrite by running the following commands:

$ sudo su - postgres
$ createuser dendriteuser
$ createdb -O dendriteuser dendritedb
$ exit

Step 3: Installing Dendrite

Download the Dendrite binary by running the following command:

$ go get github.com/matrix-org/dendrite/cmd/dendrite

This command will download Dendrite and all its dependencies.

Now, navigate to the Dendrite configuration directory:

$ cd $GOPATH/src/github.com/matrix-org/dendrite/cmd/dendrite/
$ cp config/dendrite.yaml.sample dendrite.yaml

Edit the dendrite.yaml file:

$ nano dendrite.yaml

Set the following fields:

database:
  connection_string: dbname=dendritedb host=localhost user=dendriteuser password=yourpassword sslmode=disable

Save and close the file.

Step 4: Start Dendrite

Now that we have installed and configured Dendrite, we can start the server by running the following command:

$ dendrite-monolith-server # for a single server installation

If you want to run Dendrite as a daemon, use the following command instead:

$ dendrite-monolith-server -daemon

To stop the server, run the following command:

$ dendrite-monolith-server -shutdown

Conclusion

In this tutorial, we learned how to install and configure Dendrite, an alternative Matrix homeserver written in Golang on FreeBSD Latest. Now that you have installed Dendrite, you can start exploring the Matrix network and interact with other users.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!