Matrix - ArchWiki

Jump to content

# Matrix

2 languages

- 日本語
- 中文（简体）

From ArchWiki

Matrix is an ambitious new ecosystem for open federated instant messaging and VoIP. It consists of servers, clients and bridge software to connect to existing messaging solutions like IRC.

A Matrix space for Arch Linux exists at #public-space:archlinux.org. Please contact any existing member or @heftig:archlinux.org for an invite. Some international communities have their own matrix rooms; see International communities for details.

For clients, see List of applications/Internet#Matrix clients.

You can either use an existing server like https://matrix.org or host your own Synapse server, which is described below.

## Installation

The reference server implementation Synapse is available as matrix-synapse, which creates a synapse user.

## Configuration

After installation, a configuration file needs to be generated. It should be readable by the synapse user:

    # generate_config --server-name my.domain.name \
                      --config-dir /etc/synapse \
                      --data-dir /var/lib/synapse \
                      --report-stats yes \
                      --generate-secrets \
                      --output-file /etc/synapse/homeserver.yaml

    # generate_log_config -o /etc/synapse/my.domain.name.log.config \
                          -f /var/log/synapse/homeserver.log

    # generate_signing_key --output_file /etc/synapse/my.domain.name.signing.key

    # chown -R synapse:synapse /etc/synapse /var/log/synapse

Note that this will generate corresponding SSL keys and self-signed certificates for the specified server name. You have to regenerate those if you change the server name.

If your Synapse server is meant to be accessed over the internet, it is highly recommended to configure a reverse proxy.

## Databases

Synapse uses SQLite only to test the server, Postgres is used for operation.

To use Postgres you will need to install the python-psycopg2 package.

You can read more about installation and configuration on the official website: Using Postgres

## Service

The `synapse.service` systemd service is included in the matrix-synapse package. It will start the synapse server as user synapse and use the configuration file `/etc/synapse/homeserver.yaml`.

## User management

You need at least one user on your fresh synapse server. You may create one as your normal non-root user with the command

    [synapse]$ register_new_matrix_user -c /etc/synapse/homeserver.yaml http://127.0.0.1:8008

or using one of the matrix clients, for example element-desktop, or the purple-matrix-gitAUR plug-in for libpurple.

## Spider webcrawler

To enable the webcrawler, for server generated link previews, the additional packages python-lxml and python-netaddr have to be installed. After that, the option `url_preview_enabled: True` can be set in your `homeserver.yaml`. To prevent the synapse server from issuing arbitrary GET requests to internal hosts, the `url_preview_ip_range_blacklist:` has to be set.

Warning: The blacklist is blank by default: without configuration the synapse server can crawl all your internal hosts.

There are some examples that can be uncommented. Add your local IP ranges to that list to prevent the synapse server from trying to crawl them. After changing the `homeserver.yaml`, the service has to be restarted.

## Interesting channels

A Matrix space for Arch Linux exists at #public-space:archlinux.org. Please contact any existing member or @heftig:archlinux.org for an invite. Some international communities have their own matrix rooms; see International communities for details.

KDE community has a wide variety of matrix rooms for specific applications, languages, events and etc. See https://community.kde.org/Matrix for details.

The GNOME Community also has a Matrix instance for its instant communications with a wide variety of matrix rooms. See https://wiki.gnome.org/GettingInTouch/Matrix for details.

## Troubleshooting

### Read-only file system

By default, synapse can only write to the working-directory (`/var/lib/synapse`) set in its service file. A write-error may occur if synapse writes to a different path (e.g. your media-store is in `/var/lib/matrix-synapse/media`).

You can allow access to other directories by creating a replacement unit file for `synapse.service` and by adding `ReadWritePaths=your_paths` to the `[Service]` section.

### High memory consumption

The memory consumption of Synapse can be significantly reduced[1] by installing jemalloc. To enable it, the environment variable `LD_PRELOAD` must be set accordingly. This can be done by creating `/etc/default/synapse`, which will be applied by the systemd unit file.[2]

    /etc/default/synapse

    LD_PRELOAD=/usr/lib/libjemalloc.so

After enabling jemalloc, the memory footprint can be reduced further by tuning cache settings: [3]

    /etc/synapse/homeserver.yaml

    caches:
      cache_autotuning:
        max_cache_memory_usage: 1024M
        target_cache_memory_usage: 758M
        min_cache_ttl: 5m

The configuration options under `cache_autotuning` will not work unless jemalloc is enabled.

Categories:

- Instant messaging
- Voice over IP