-
Notifications
You must be signed in to change notification settings - Fork 0
Setting up a Synapse Server
Synapse is the reference Python/Twisted Matrix homeserver implementation.
System requirements:
- POSIX-compliant system (tested on Linux & OS X)
- Python 2.7
- At least 1GB of free RAM if you want to join large public rooms like #matrix:matrix.org
(Prebuilt packages are available for some platforms - see Platform-Specific Instructions.)
Synapse is written in Python but some of the libraries it uses are written in C. So before we can install Synapse itself we need a working C compiler and the header files for Python C extensions.
Installing prerequisites on Ubuntu or Debian:
sudo apt-get install build-essential python2.7-dev libffi-dev \ python-pip python-setuptools sqlite3 \ libssl-dev python-virtualenv libjpeg-dev libxslt1-dev
Installing prerequisites on ArchLinux:
sudo pacman -S base-devel python2 python-pip \ python-setuptools python-virtualenv sqlite3
Installing prerequisites on CentOS 7 or Fedora 25:
sudo yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel \ lcms2-devel libwebp-devel tcl-devel tk-devel redhat-rpm-config \ python-virtualenv libffi-devel openssl-devel sudo yum groupinstall "Development Tools"
Installing prerequisites on Mac OS X:
xcode-select --install sudo easy_install pip sudo pip install virtualenv brew install pkg-config libffi
Installing prerequisites on Raspbian:
sudo apt-get install build-essential python2.7-dev libffi-dev \ python-pip python-setuptools sqlite3 \ libssl-dev python-virtualenv libjpeg-dev sudo pip install --upgrade pip sudo pip install --upgrade ndg-httpsclient sudo pip install --upgrade virtualenv
Installing prerequisites on openSUSE:
sudo zypper in -t pattern devel_basis sudo zypper in python-pip python-setuptools sqlite3 python-virtualenv \ python-devel libffi-devel libopenssl-devel libjpeg62-devel
Installing prerequisites on OpenBSD:
doas pkg_add python libffi py-pip py-setuptools sqlite3 py-virtualenv \ libxslt jpeg
To install the Synapse homeserver run:
virtualenv -p python2.7 ~/.synapse source ~/.synapse/bin/activate pip install --upgrade pip pip install --upgrade setuptools pip install matrix-synapse
This installs Synapse, along with the libraries it uses, into a virtual
environment under ~/.synapse
. Feel free to pick a different directory
if you prefer.
This Synapse installation can then be later upgraded by using pip again with the update flag:
source ~/.synapse/bin/activate pip install -U matrix-synapse
In case of problems, please see the Troubleshooting section below.
There is an offical synapse image available at https://hub.docker.com/r/matrixdotorg/synapse/tags/ which can be used with the docker-compose file available at contrib/docker. Further information on this including configuration options is available in the README on hub.docker.com.
Alternatively, Andreas Peters (previously Silvio Fricke) has contributed a Dockerfile to automate a synapse server in a single Docker image, at https://hub.docker.com/r/avhost/docker-matrix/tags/
Slavi Pantaleev has created an Ansible playbook, which installs the offical Docker image of Matrix Synapse along with many other Matrix-related services (Postgres database, riot-web, coturn, mxisd, SSL support, etc.). For more details, see https://github.com/spantaleev/matrix-docker-ansible-deploy
Matrix provides official Debian packages via apt from https://matrix.org/packages/debian/. Note that these packages do not include a client - choose one from https://matrix.org/docs/projects/try-matrix-now.html (or build your own with one of our SDKs :)
Synapse is in the Fedora repositories as matrix-synapse
:
sudo dnf install matrix-synapse
Oleg Girko provides Fedora RPMs at https://obs.infoserver.lv/project/monitor/matrix-synapse
Synapse is in the OpenSUSE repositories as matrix-synapse
:
sudo zypper install matrix-synapse
Unofficial package are built for SLES 15 in the openSUSE:Backports:SLE-15 repository at https://download.opensuse.org/repositories/openSUSE:/Backports:/SLE-15/standard/
The quickest way to get up and running with ArchLinux is probably with the community package https://www.archlinux.org/packages/community/any/matrix-synapse/, which should pull in most of the necessary dependencies. If the default web client is to be served (enabled by default in the generated config), https://www.archlinux.org/packages/community/any/python2-matrix-angular-sdk/ will also need to be installed.
Alternatively, to install using pip a few changes may be needed as ArchLinux defaults to python 3, but synapse currently assumes python 2.7 by default:
pip may be outdated (6.0.7-1 and needs to be upgraded to 6.0.8-1 ):
sudo pip2.7 install --upgrade pip
You also may need to explicitly specify python 2.7 again during the install request:
pip2.7 install https://github.com/matrix-org/synapse/tarball/master
If you encounter an error with lib bcrypt causing an Wrong ELF Class: ELFCLASS32 (x64 Systems), you may need to reinstall py-bcrypt to correctly compile it under the right architecture. (This should not be needed if installing under virtualenv):
sudo pip2.7 uninstall py-bcrypt sudo pip2.7 install py-bcrypt
During setup of Synapse you need to call python2.7 directly again:
cd ~/.synapse python2.7 -m synapse.app.homeserver \ --server-name machine.my.domain.name \ --config-path homeserver.yaml \ --generate-config
...substituting your host and domain name as appropriate.
Synapse can be installed via FreeBSD Ports or Packages contributed by Brendan Molloy from:
- Ports:
cd /usr/ports/net-im/py-matrix-synapse && make install clean
- Packages:
pkg install py27-matrix-synapse
There is currently no port for OpenBSD. Additionally, OpenBSD's security settings require a slightly more difficult installation process.
- Create a new directory in
/usr/local
called_synapse
. Also, create a new user called_synapse
and set that directory as the new user's home. This is required because, by default, OpenBSD only allows binaries which need write and execute permissions on the same memory space to be run from/usr/local
. -
su
to the new_synapse
user and change to their home directory. - Create a new virtualenv:
virtualenv -p python2.7 ~/.synapse
- Source the virtualenv configuration located at
/usr/local/_synapse/.synapse/bin/activate
. This is done inksh
by using the.
command, rather thanbash
'ssource
. - Optionally, use
pip
to installlxml
, which Synapse needs to parse webpages for their titles. - Use
pip
to install this repository:pip install matrix-synapse
- Optionally, change
_synapse
's shell to/bin/false
to reduce the chance of a compromised Synapse server being used to take over your box.
After this, you may proceed with the rest of the install directions.
Robin Lambertz has packaged Synapse for NixOS at: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/matrix-synapse.nix
If you wish to run or develop Synapse on Windows, the Windows Subsystem For Linux provides a Linux environment on Windows 10 which is capable of using the Debian, Fedora, or source installation methods. More information about WSL can be found at https://docs.microsoft.com/en-us/windows/wsl/install-win10 for Windows 10 and https://docs.microsoft.com/en-us/windows/wsl/install-on-server for Windows Server.
Matrix serves raw user generated data in some APIs - specifically the content repository endpoints.
Whilst we have tried to mitigate against possible XSS attacks (e.g. https://github.com/matrix-org/synapse/pull/1021) we recommend running matrix homeservers on a dedicated domain name, to limit any malicious user generated content served to web browsers a matrix API from being able to attack webapps hosted on the same domain. This is particularly true of sharing a matrix webclient and server on the same domain.
See https://github.com/vector-im/vector-web/issues/1977 and https://developer.github.com/changes/2014-04-25-user-content-security for more details.
Continue to Configuring Synapse
The instructions for upgrading synapse are in UPGRADE.rst. Please check these instructions as upgrading may require extra steps for some versions of synapse.
Synapse for Server Operators
- Setting up a Synapse Server
- Configuring Synapse
- Server Maintenance
- Upgrading Synapse
- Troubleshooting
Synapse for Developers