meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
digital:server:matrixsynapse [2019/05/30 12:57]
natrius
digital:server:matrixsynapse [2020/06/17 19:32]
natrius [Step 2 - Install Synapse] - spelling mistake
Line 39: Line 39:
 sudo apt install -y lsb-release wget apt-transport-https sudo apt install -y lsb-release wget apt-transport-https
 sudo wget -O /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg sudo wget -O /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg
-echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" | +echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/matrix-org.list
-    sudo tee /etc/apt/sources.list.d/matrix-org.list+
 </code> </code>
  
Line 64: Line 63:
     sudo systemctl enable matrix-synapse.service     sudo systemctl enable matrix-synapse.service
  
-Synapse is now up and running using the default configuration on port '8008' and '8448'. Check the open ports using netstat command.+Synapse is now up and running using the default configuration on port '8008' and '8448'. Check the open ports using ss (former netstatcommand.
  
-    sudo ss -plntu+    ss -plntu
  
-#### Set up well.known+#### Set up .well-known
  
-On your webserver a file at ''%%/.well-known/matrix/server%%'' has to be set up with the follwoing content +On your webserver a file at ''%%/.well-known/matrix/server%%'' has to be set up with the following content 
  
 <code> <code>
Line 79: Line 78:
  
 Where ''/'' is the root of your webserver. So if you navigate to ''https://example.com/.well-known/matrix.server'' it may try to download the ''server'' file or show it directly. Where ''/'' is the root of your webserver. So if you navigate to ''https://example.com/.well-known/matrix.server'' it may try to download the ''server'' file or show it directly.
- 
-#### Set up SRV 
- 
-By setting an SRV record in your DNS provider, it is possible to tell other matrix servers where to connect to the server, pointing them to the correct hostname and port, in this example the default port (8448) is still used: 
- 
-<code> 
-_matrix._tcp.example.com. 3600 IN SRV 10 5 443 synapse.example.com. 
-</code> 
- 
-There is still an A record needed, pointing to the IP-addess of synapse on the subdomain (matrix.example.com). This way others can add your user with ''@user:example.com'' instead of ''@user:matrix.example.com''. 
  
 ### Step 3 - Configure Synapse ### Step 3 - Configure Synapse
Line 104: Line 93:
 ''%%enable_registration%%: False'' ''%%enable_registration%%: False''
  
-''%%registration_shared_secret%%: "%%[shared_secred_key]%%"''+''%%registration_shared_secret%%: %%[shared_secred_key]%%''
  
-#### Check listener and federation port+#### Check ports
  
-Now check the HTTP and HTTPS listener port '8008' and the federation port '8448'**The best is to leave it default as it comes delivered** (watch here https://github.com/matrix-org/synapse/blob/master/docs/sample_config.yaml ), so check if it matches the follwing:+**The best is to leave it default as it comes delivered** (watch here https://github.com/matrix-org/synapse/blob/master/docs/sample_config.yaml ), so check if it matches the follwing:
  
 <code>sudoedit /etc/matrix-synapse/homeserver.yaml</code> <code>sudoedit /etc/matrix-synapse/homeserver.yaml</code>
Line 128: Line 117:
 Now restart the Synapse services. Now restart the Synapse services.
  
-    sudo systemctl reload matrix-synapse.service+    sudo systemctl restart matrix-synapse.service
  
 Check the homeserver service with the following command Check the homeserver service with the following command
  
-    sudo ss -plntu+    ss -plntu
  
 You will get the Synapse service is now on the local IP address. And we have completed the Synapse installation and configuration. You will get the Synapse service is now on the local IP address. And we have completed the Synapse installation and configuration.
Line 265: Line 254:
 Nginx installation and configuration as a reverse proxy for the Synapse homeserver has been completed. Nginx installation and configuration as a reverse proxy for the Synapse homeserver has been completed.
  
-### (Optional) Step 6 - Postgre instead of sqlite+### (Optional) Step 6 - PostgreSQL instead of sqlite
  
 While the step is marked as optional, it is **strongly encouraged** for any server that isn't purely for testing. While the step is marked as optional, it is **strongly encouraged** for any server that isn't purely for testing.
  
-#### Initial Postgresql setup+#### Initial PostgreSQL setup
  
 <code>sudo apt install postgresql</code> <code>sudo apt install postgresql</code>
Line 277: Line 266:
 <code>postgres=# CREATE DATABASE synapse ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER "username";</code> <code>postgres=# CREATE DATABASE synapse ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER "username";</code>
  
-Where username can be "matrix_synapse", and password is a new strong password you set for postgresql.+Where username can be ''synapse_user'', and password is a new strong password you set for postgresql.
  
 To end the postgre line just type in ''\q'' and close the postegre-usershell with ''exit'' To end the postgre line just type in ''\q'' and close the postegre-usershell with ''exit''
  
-#### Set up Postgre for Synapse+#### Set up PostgreSQL for Synapse
  
 <code>sudo apt install python3-psycopg2</code> <code>sudo apt install python3-psycopg2</code>
Line 302: Line 291:
  
   * ''user'' is in this case ''synapse_user''   * ''user'' is in this case ''synapse_user''
-  * ''Database'' should be the full path to the db, example ''"/var/lib/matrix-synapse/homeserver.db"''+  * ''Database'' should be the above created db, example ''synapse''
   * ''Host'' is the postgre hostname, usally ''/var/run/postgresql/'' or ''127.0.0.1''   * ''Host'' is the postgre hostname, usally ''/var/run/postgresql/'' or ''127.0.0.1''
  
Line 308: Line 297:
  
 <code> <code>
-sudo systemctl reload matrix-synapse.service+sudo systemctl restart matrix-synapse.service
 </code> </code>
  
 ### Migrating from SQlite to PostgreSQL ### Migrating from SQlite to PostgreSQL
  
-There is no need for this if you have nothing done yet with synapse, otherwise, please refer to https://github.com/matrix-org/synapse/blob/master/docs/postgres.rst+Assuming you already followed step 6, there is no need for a migration. If you already used your Synapse and want to migrate, please refer to https://github.com/matrix-org/synapse/blob/master/docs/postgres.md
  
 ### Step 7 - Setup UFW Firewall ### Step 7 - Setup UFW Firewall
Line 333: Line 322:
 At this stage, the Synapse homeserver installation and configuration is complete. And in this step, we need to add a new matrix user from the command line on the server. To create a new matrix user, run the command below. At this stage, the Synapse homeserver installation and configuration is complete. And in this step, we need to add a new matrix user from the command line on the server. To create a new matrix user, run the command below.
  
-    register_new_matrix_user -c homeserver.yaml http://localhost:8008+    register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml http://localhost:8008
  
 Now you need to input the user name, password, and decide whether the user will have the admin privileges or not. And we have created a new matrix user with admin privilege. Now you need to input the user name, password, and decide whether the user will have the admin privileges or not. And we have created a new matrix user with admin privilege.
  
-### Step 9 - Federation +### Step 9 - Testing
- +
-You can test if federation is working using https://federationtester.matrix.org. If any of the checks show an error then federation won't work. Other federation-testers include: +
- +
-  * https://fed.mau.dev/ +
- +
-### Step 10 - Testing+
  
 If you have used Riot with the desktop application before you may not want to log out, so it is better to go to [[https://riot.im/app/]] and press "Launch now". If you have used the web client before, download the Riot desktop application, install it and open the Riot software. With both you will get the Matrix login page now. Type the matrix username and password, then choose the 'Custom server' option and type the domain name from your server ''example.com'' in. Click the ''Sign In'' button and you will get to the Riot Dashboard. If you have used Riot with the desktop application before you may not want to log out, so it is better to go to [[https://riot.im/app/]] and press "Launch now". If you have used the web client before, download the Riot desktop application, install it and open the Riot software. With both you will get the Matrix login page now. Type the matrix username and password, then choose the 'Custom server' option and type the domain name from your server ''example.com'' in. Click the ''Sign In'' button and you will get to the Riot Dashboard.
Line 351: Line 334:
 If you need two instances of riot instead, you can start it with argument, refer to [[digital:software:riotim|Riot.im]]. If you need two instances of riot instead, you can start it with argument, refer to [[digital:software:riotim|Riot.im]].
  
-For another way to test it, go to ''https://example.com/_matrix/client/versions'' and the output should look like the following:+For another way to test it, go to ''https://example.com/_matrix/static/'' and you will be presented with a ''**It works! Synapse is running**'' screen or go to ''https://example.com/_matrix/client/versions'' and the output should look like the following:
  
 <code xml> <code xml>
Line 362: Line 345:
 3 "r0.3.0" 3 "r0.3.0"
 </code> </code>
 +
 +### Step 10 - Federation
 +
 +You can test if federation is working using https://federationtester.matrix.org. If any of the checks show an error then federation won't work. Other federation-testers include:
 +
 +  * https://fed.mau.dev/
  
 ## Explanations ## Explanations
Line 427: Line 416:
  
 ### Location of logs ### Location of logs
 +
 +Check matrix with ''%%journalctl -xe%%'' and ''%%systemctl status matrix-synapse%%''
 +
 +A good way to check the logs is ''%%tail -20 [PATH]%%''. ''tail'' will show the last lines of a file, with ''-20'' it is possible to see the last 20 lines.
 +
 +#### Matrix
  
 <code> <code>
-/etc/matrix-synapse/homeserver.log  
 /var/log/matrix-synapse/homeserver.log /var/log/matrix-synapse/homeserver.log
 +</code>
 +
 +#### Nginx
 +
 +<code>
 +/var/log/nginx/error.log
 +/var/log/nginx/application.log
 </code> </code>
  
Line 465: Line 466:
 For feedback about this guide or tips on how to improve it visit https://matrix.to/#/#synapseguide:matrix.org For feedback about this guide or tips on how to improve it visit https://matrix.to/#/#synapseguide:matrix.org
  
-### ToDo 
- 
-  * More explanations (explain more, because open source documentation is famously sparse) 
-    * what nginx 
-    * reverse proxy 
-    * what is postgre and why is it preferred over sqlite