
Matrix is an open standard for decentralized and end-to-end encrypted communication. It federates using homeservers that communicate with each other over the internet. Homeservers store data about their users and the chat history of rooms created (including rooms originating from other homeservers). Due to the nature of decentralization, when the original homeserver that created a room goes offline, other homeservers can continue communication without issues. Because of this design, there is not a single point of failure.
Synapse is a reference implementation of a Matrix homeserver created by the Matrix.org team and is also the most popular, mature, and complete implementation.
When following this guide, replace all occurrences of example.org with your domain name.
matrix, element, and turn subdomains to your serverAdd the Matrix.org apt repository.
Install Synapse.
During the installation, enter the name of the homeserver, which forms part of your Matrix ID. You can change this later in /etc/matrix-synapse/conf.d/server_name.yaml.
While Synapse supports using SQLite as a database, it is not recommended in production because of performance issues.
Install PostgreSQL.
Log into the PostgreSQL user.
Create a user synapse and a database synapse for PostgreSQL.
Leave the postgres account.
Synapse supports running standalone without a reverse proxy, but it is not recommended in production.
Install Nginx and Certbot.
Open the HTTP, HTTPS, and Synapse ports in the firewall.
Get a TLS certificate from Let's Encrypt.
Create a new Nginx configuration file.
Add the following lines to the configuration file.
If the DNS records for the Matrix server name set during Synapse installation (example.org) are pointing to IP address of the same server that hosts Synapse (matrix.example.org), add the following lines at the end of /etc/nginx/sites-available/synapse. If not, add the following lines on that other server (example.org) in an appropriate location for Nginx configuration files.
Enable configuration.
Reload Nginx configuration.
You could edit the configuration file at /etc/matrix-synapse/homeserver.yaml, but you should instead place changes in /etc/matrix-synapse/conf.d/ so apt does not ask to overwrite the configuration file after each update of Synapse.
Create a new database configuration file.
Add the following lines to the configuration file. Replace the password value with the password set earlier for the PostgreSQL synapse user. If you are hosting PostgreSQL on a different server, replace localhost with its address.
Create a secret registration key. Keep it secure because anyone with the key can register a new user, even if registration is disabled.
By default, Synapse enables presence indicators that show if a person is online. This may cause high CPU usage, and many homeservers disable them. To do so, create a new configuration file.
Add the following lines to the configuration file.
Restart Synapse to apply the new configuration.
Create a new Matrix user.
To open public registration, create a new configuration.
Add the following lines to the configuration file.
By default, Synapse does not allow registration without verification. To enable email verification, add the following lines.
To not have any form of verification, add the following line.
Restart Synapse to apply new configuration.
To verify that Synapse is running, open /_matrix/static/ on your Matrix domain in your browser. For example:
To check if federation with other homeservers is working, open the Federation Tester, type in your Matrix server name, and click Go.
You usually need a Traversal Using Relays around NAT (TURN) server to get voice and video calls working. If you don't need this functionality, you can skip this section.
Install Coturn.
Open the TURN and UDP firewall ports.
Get a TLS certificate from Let's Encrypt.
Generate an authentication secret.
Edit the configuration file.
Add the following lines to the configuration file.
Restart Coturn to reload configuration.
Create a new Synapse configuration file.
Add the following lines to the configuration file. Replace turn_shared_secret value with the value of static-auth-secret from /etc/turnserver.conf.
Restart Synapse to apply the new configuration.
Synapse is now configured, and you can use it with any Matrix client. Element is the most popular Matrix client that is available as a hosted web app, desktop, and mobile application.
If you want to host your own instance of Element, read further for instructions on how to install and configure it.
To log in on your Matrix client, type your full Matrix ID (for example, @bob:example.org) in the username field. Most clients like Element automatically fetch the homeserver information. If that does not work, check if the /.well-known/matrix/client/ URL on your Matrix server has the correct homeserver information. If it does, your client does not support homeserver discovery, and you need to insert the homeserver address manually.
Install jq.
Create a directory for Element.
Create a new file for fetching the newest Element release.
Add the following lines to the file.
Mark file as executable.
Execute the file to download Element.
To update Element in the future, re-run the command.
Copy the sample Element configuration.
Edit the configuration file.
Change the default Matrix.org homeserver address to your homeserver.
If you want to use your own name instead of Element in the website title and other places, change the brand name.
Get a TLS certificate from Let's Encrypt.
Create a new Nginx configuration file.
Add the following lines to the configuration file.
Enable configuration.
Reload the Nginx configuration.
You can now access Element from the element subdomain (for example, https://element.example.org). To log in, type your username or full Matrix ID.
0 Comments
Be the first to comment and share your perspective with the community.