Introduction
Synapse is the reference implementation of the Matrix server, an open protocol for real-time decentralized communication. Install Synapse on a Linux system allows you to create your own chat, video calls and collaboration environment without relying on central services. This article shows step by step how to prepare the environment, install the dependencies, configure Synapse and keep it safe.
Previous requirements
You need a recent Linux distribution (Ubuntu 22.04 LTS, Debian 12 or Fedora 38) with root or sweat access, at least 2 GB RAM and 20 GB disk space. A domain name is recommended by pointing to the server IP and a valid TLS certificate (e.g. from Let's Encrypt).
System units
In Debian / Ubuntu:
sudo apt updatesudo apt install -y python3-pip python3-virtualenv libffi-dev libssl-dev build-essentialsudo apt install -y libjpeg-turbo8-dev libpng-dev libwebp-dev
In Fedora:
sudo dnf install -y python3-pip python3-virtualenv gcc libffi-devel openssl-devel makesudo dnf install -y libjpeg-turbo-devel libpng-devel libwebp-devel
Create a virtual environment
To isolate the installation, create a directory and a virtual environment:
sudo mkdir -p /opt/synapsesudo chown $USER:$USER /opt/synapsecd /opt/synapsepython3 -m venv envsource env/bin/activate
Install Synapse
With the activated environment, install Synapse and the PostgreSQL adapter:
pip install --upgrade pip setuptools wheelpip install synapse[postgres]
Generate the initial configuration
Run the configuration creation command:
python -m synapse.app.homeserver --server-name mi.dominio.com --config-path homeserver.yaml --generate-config --report-stats=no
This will producehomeserver.yamlandhomeserver.signing.key. Edit the YAML to:
- Define
listeners(port 8008, optional TLS). - Configure Section
databasewith the PostgreSQL data. - Set
registration_shared_secretwith a random value. - Decide if you allow open records (
enable_registration: true) or only by invitation.
Configure PostgreSQL
If you use PostgreSQL, create the database and user:
sudo -u postgres psql- Within psql:
CREATE DATABASE synapse; CREATE USER synapse_user WITH PASSWORD 'tu_contraseña_segura';GRANT ALL PRIVILEGES ON DATABASE synapse TO synapse_user;\q
Then adjust the sectiondatabaseofhomeserver.yamlwith those credentials.
Run Synapse as Service
Create a system unit file for Synapse to boot at the start:
sudo nano /etc/systemd/system/synapse.service
Content:
[Unit] Description = Synapse Matrix HomeserverAfter = network.target [Service] Type = simpleUser = your _ usuarioWorkingDirectory = / opt / synapseEnvironment = "PATH = / opt / synapse / env / bin" ExecStart = / opt / synapse / env / bin / python -m synapse.app.homeserver --config-path / opt / synapse / homes.com.and -Rester.and [Inster.and]
Replacementtu_usuarioby the owner of/opt/synapse. Then:
sudo systemctl daemon-reloadsudo systemctl enable synapse.servicesudo systemctl start synapse.servicesudo systemctl status synapse.service
Security and good practices
- Use a TLS certificate from Let's Encrypt and define
tls_certificate_pathandtls_private_key_pathin the YAML. - Restrict access to port 8008 (or 443 if you use a proxy) with
ufworfirewalld. - Disable open registration (
enable_registration: false) and uses invitations or SSO. - Configure log rotation with
logrotate. - Keep the environment up to date:
pip install --upgrade synapsewithin the environment and restart the service.
Monitoring and maintenance
Synapse exposition metrics in/_synapse/metricsfor Prometheus. The filehomeserver.logcontains information on errors and warnings. Configure achieve:
sudo nano /etc/logrotate.d/synapse- Content:
/ opt / synapse / homeserver.log {weekly rotate 4 compressor missingok notifempty}
To update, reactivate the environment, runpip install --upgrade synapseand restart withsudo systemctl restart synapse.service.
Conclusion
Install Synapse in Linux is an accessible process that gives you full control over your Matrix-based communication. With the above steps you will have a secure server, ready to integrate bridges, bots and collaboration applications. Encourage yourself to deploy your own node and contribute to the decentralized network of safe messaging.


