Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      OpenProject ID Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Boards
    Boards
  • Wiki
    Wiki
  • News

Content

Wiki
  1. Stream Matrix Hookshot - Element Integration
  2. Wiki
  3. Matrix homeserver setup on local machine using Python
More
  • Print
  • Table of contents

Matrix homeserver setup on local machine using Python

More
  • Print
  • Table of contents
Export
Export
  • Atom
  • Markdown

Version 1/1 — Girish M — 01/21/2025 04:20 AM

Setup of Matrix homeserver

Running a Matrix homeserver (like Synapse) on localhost without DNS can be done for testing and development purposes.
Here's a general outline of the steps that needs to be followed:

  1. Prerequisites:

    • Install Python: Synapse is written in Python, so make sure you have Python installed on your system.

    • Install pip: This is the Python package manager, which you'll use to install Synapse.

    • Configure Python virtual environment for all subsequent installations like this:

python3 -m venv path/to/venv
source path/to/venv/bin/activate
pip install package_name
  1. Install Synapse:
    You can install Synapse using pip. Open a terminal and run the following command:
pip install matrix-synapse
  1. Configure Synapse:
    Create a configuration file for Synapse. You can generate a basic configuration file using the following command:
python -m synapse.app.homeserver --server-name your.server.name --config-path /path/to/config
  1. Replace your.server.name with a unique server name. Modify the generated configuration file (/path/to/config) to your requirements.

    In your configuration file, you may want to set the listeners section to bind the server to your localhost IP (e.g., "127.0.0.1") on a specific port (e.g., 8008) to ensure that it only listens on your local machine.

  2. Create a Self-Signed Certificate:
    For testing purposes, you can create a self-signed SSL certificate. This step is optional but recommended if you want to use HTTPS.

    You can create a self-signed certificate using tools like OpenSSL.

openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -keyout server.key -out server.crt
  1. Then, configure your Synapse server to use these certificates in your configuration file.

  2. Database Configuration:
    Configure the database settings in your Synapse configuration file. For Postgres follow these steps:

    • Install PostgresSQL client library
sudo apt install postgresql postgresql-contrib
  • To interact with database use 'postgres' user profile
sudo -u postgres bash
  • Then create a postgres user with username 'synapse_user'
createuser --pwprompt synapse_user
  • Create a database for synapse home-server with database name 'synapse'
createdb --encoding=UTF8 --locale=C --template=template0 --owner=synapse_user synapse 
  • Exit from postgres
exit
  • Setup postgres database for synapse home-server. Un-comment and edit listen_address variable in postgresql.conf


    located at /etc/postgresql/<postgres_version>/main/postgresql.conf.


    For version 15:

sudo nano /etc/postgresql/15/main/postgresql.conf
  • Find the following line and edit as such:
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = 'localhost'          # what IP address(es) to listen on; 
  • Save and exit.

  • Then edit pg_hba.conf file and add a line to enable password authentication so that 'synapse_user' can connect to


    'synapse' database

sudo nano /etc/postgresql/15/main/pg_hba.conf
  • Add the following line at the end of file
local   synapse         synapse_user                            md5
  • So that it looks like
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5
local   synapse         synapse_user                            md5
  • Add the 'synapse config' of the above database to config.yaml, so it looks something like this
database:
name: psycopg2
args:
user: synapse_user
password: <pass>
database: synapse
host: localhost
cp_min: 5
cp_max: 10
  • Install psycopg2 in Python virtual environment
pip install psycopg2
pip install psycopg2-binary
  1. Start the Homeserver:
    To start the Synapse server, use the following command:
python -m synapse.app.homeserver --config-path /path/to/config
  1. Access your Homeserver:
    You can access your Matrix homeserver by using a Matrix client such as Element. Point your client to your localhost IP and the port you configured in the listeners section. For example, http://127.0.0.1:8008.

  2. User Registration:
    Register a new user on your homeserver using your Matrix client.

Remember that running a homeserver without DNS means you won't be able to access it from other devices on your network or the internet. It's suitable for local testing and development purposes. If you want to make your homeserver accessible outside your localhost, you'll need to configure DNS and network settings accordingly.

References

  • Matrix homeserver setup guide

  • Matrix homeserver configuration guide

Loading...