2022-02-06 17:48:06 +01:00
## Installing Conduit with a binary
2020-08-12 21:17:53 +02:00
2022-02-06 17:48:06 +01:00
{{#include ../_getting_help.md}}
2020-08-12 21:17:53 +02:00
2022-02-06 17:48:06 +01:00
## Prerequisites
2020-08-12 21:17:53 +02:00
2022-02-06 17:48:06 +01:00
Although you might be able to compile Conduit for Windows, we do recommend running it on a Linux server.
2021-07-11 11:43:48 +00:00
2022-02-06 17:48:06 +01:00
This guide assumes you have root access to a Debian Linux server with at least 1 GB of available RAM and at least 10 GB of free disk space.
The more chats you join and the bigger these chats are, the more RAM and storage you'll need.
2021-07-11 11:43:48 +00:00
2022-02-06 17:48:06 +01:00
As Matrix uses HTTPS for communication, you'll also need a domain, like `matrix.org` . Whenever you see `your.server.name` in this guide, replace it with your actual domain.
## Download Conduit
You may simply download the binary that fits your machine. Run `uname -m` to see what you need. Now copy the right URL:
| CPU Architecture | Download stable version | Download development version |
| -------------------- | ------------------------------ | ---------------------------- |
| x84_64 / amd64 | [Download][x84_64-musl-master] | [Download][x84_64-musl-next] |
| armv6 | [Download][armv6-musl-master] | [Download][armv6-musl-next] |
| armv7 (Raspberry Pi) | [Download][armv7-musl-master] | [Download][armv7-musl-next] |
| armv8 / aarch64 | [Download][armv8-musl-master] | [Download][armv8-musl-next] |
2021-11-25 22:36:44 +00:00
[x84_64-musl-master]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-musl?job=build:release:cargo:x86_64-unknown-linux-musl
[armv6-musl-master]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-arm-unknown-linux-musleabihf?job=build:release:cargo:arm-unknown-linux-musleabihf
[armv7-musl-master]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-armv7-unknown-linux-musleabihf?job=build:release:cargo:armv7-unknown-linux-musleabihf
[armv8-musl-master]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-aarch64-unknown-linux-musl?job=build:release:cargo:aarch64-unknown-linux-musl
2022-02-04 17:57:59 +01:00
[x84_64-musl-next]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/next/raw/conduit-x86_64-unknown-linux-musl?job=build:release:cargo:x86_64-unknown-linux-musl
[armv6-musl-next]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/next/raw/conduit-arm-unknown-linux-musleabihf?job=build:release:cargo:arm-unknown-linux-musleabihf
[armv7-musl-next]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/next/raw/conduit-armv7-unknown-linux-musleabihf?job=build:release:cargo:armv7-unknown-linux-musleabihf
[armv8-musl-next]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/next/raw/conduit-aarch64-unknown-linux-musl?job=build:release:cargo:aarch64-unknown-linux-musl
2020-10-20 14:18:20 +02:00
2020-08-12 21:17:53 +02:00
```bash
2022-02-06 17:48:06 +01:00
sudo wget -O /usr/local/bin/matrix-conduit < url >
sudo chmod +x /usr/local/bin/matrix-conduit
2020-08-12 21:17:53 +02:00
```
2022-02-06 17:48:06 +01:00
## Or compile the binary yourself
If you don't want to use our prebuilt binaries, you can also compile Conduit yourself.
To do so, you'll need to install Rust and some dependencies:
2022-01-28 22:26:56 -08:00
```bash
2022-02-06 17:48:06 +01:00
sudo apt install git curl libclang-dev build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
2022-01-28 22:26:56 -08:00
```
2021-08-13 17:20:40 +02:00
2022-02-06 17:48:06 +01:00
If that succeeded, clone Conduit and build it:
2021-05-27 23:13:50 +02:00
```bash
2022-02-06 17:48:06 +01:00
git clone --depth 1 "https://gitlab.com/famedly/conduit.git" conduit & & cd conduit
cargo build --release
sudo cp target/release/conduit /usr/local/bin/conduit
2021-05-27 23:13:50 +02:00
```
2021-11-21 17:34:08 +00:00
2022-02-06 17:48:06 +01:00
Note that this currently requires Rust 1.56, which should automatically be used when you installed Rust via rustup.
< details >
< summary > Cross-Compiling to different architectures< / summary >
2021-05-27 23:13:50 +02:00
2022-02-06 17:48:06 +01:00
In theory, Rust offers smooth cross-compilation. But since Conduit is not pure-Rust (due to its database choices), you can't just `cargo build --target armv7-unknown-linux-musleabihf` .
But fear not, smart people (in this case, the wonderful [Maxim ](@mdc:anter.io )) prepared some cross-images for you. So to cross-compile:
1. [Install Docker ](https://docs.docker.com/get-docker/ )
2. [Install cargo-cross ](https://github.com/cross-rs/cross#installation )
3. Choose a target and compile with `cross build --target="YOUR_TARGET_HERE" --locked --release`
Currently supported targets are:
- `aarch64-unknown-linux-musl`
- `arm-unknown-linux-musleabihf`
- `armv7-unknown-linux-musleabihf`
- `x86_64-unknown-linux-musl`
< / details >
2021-05-27 23:13:50 +02:00
2021-04-06 13:17:39 +00:00
## Adding a Conduit user
2021-04-06 12:26:47 +00:00
2022-02-06 17:48:06 +01:00
While Conduit can run as any user, it is usually better to use dedicated users for different services. This also allows
2021-11-21 17:34:08 +00:00
you to make sure that the file permissions are correctly set up.
2021-04-06 12:26:47 +00:00
2022-02-06 17:48:06 +01:00
In Debian, you can use this command to create a Conduit user:
2021-04-06 12:26:47 +00:00
2021-08-17 14:44:53 +02:00
```bash
2021-04-06 13:17:39 +00:00
sudo adduser --system conduit --no-create-home
```
2020-08-12 21:17:53 +02:00
2021-01-01 13:47:53 +01:00
## Setting up a systemd service
2020-08-12 21:17:53 +02:00
2021-11-21 17:34:08 +00:00
Now we'll set up a systemd service for Conduit, so it's easy to start/stop Conduit and set it to autostart when your
server reboots. Simply paste the default systemd service you can find below into
2021-01-01 13:47:53 +01:00
`/etc/systemd/system/conduit.service` .
2020-08-12 21:17:53 +02:00
```systemd
[Unit]
2021-01-01 13:47:53 +01:00
Description=Conduit Matrix Server
2020-08-12 21:17:53 +02:00
After=network.target
[Service]
2021-01-01 13:47:53 +01:00
Environment="CONDUIT_CONFIG=/etc/matrix-conduit/conduit.toml"
2021-04-06 12:26:47 +00:00
User=conduit
Group=nogroup
2020-08-12 21:17:53 +02:00
Restart=always
2021-01-01 13:47:53 +01:00
ExecStart=/usr/local/bin/matrix-conduit
2020-08-12 21:17:53 +02:00
[Install]
WantedBy=multi-user.target
```
Finally, run
2021-04-15 23:08:13 +02:00
2020-08-12 21:17:53 +02:00
```bash
2022-02-06 17:48:06 +01:00
sudo systemctl daemon-reload
2020-08-12 21:17:53 +02:00
```
2021-01-01 13:47:53 +01:00
## Creating the Conduit configuration file
2021-11-21 17:34:08 +00:00
Now we need to create the Conduit's config file in `/etc/matrix-conduit/conduit.toml` . Paste this in **and take a moment
to read it. You need to change at least the server name.**
2021-04-15 23:08:13 +02:00
2021-01-01 13:47:53 +01:00
```toml
2022-02-06 17:48:06 +01:00
{{#include ../../conduit-example.toml}}
2020-08-12 21:17:53 +02:00
```
2021-04-06 12:26:47 +00:00
## Setting the correct file permissions
2022-02-06 17:48:06 +01:00
As we are using a Conduit specific user, we need to allow it to read the config. To do that, you can run this command on
2021-11-21 17:34:08 +00:00
Debian:
2021-04-06 12:26:47 +00:00
2021-08-17 14:44:53 +02:00
```bash
2022-02-21 22:28:13 +01:00
sudo chown -R root:root /etc/matrix-conduit
sudo chmod 755 /etc/matrix-conduit
2021-04-06 13:17:39 +00:00
```
2021-04-06 12:26:47 +00:00
2022-02-06 17:48:06 +01:00
If you use the default database path, you also need to run this:
2021-04-06 13:17:39 +00:00
2021-08-17 14:44:53 +02:00
```bash
2022-02-13 12:15:40 +00:00
sudo mkdir -p /var/lib/matrix-conduit/
sudo chown -R conduit:nogroup /var/lib/matrix-conduit/
2022-02-21 22:35:08 +01:00
sudo chmod 700 /var/lib/matrix-conduit/
2021-04-06 13:17:39 +00:00
```
2021-04-06 12:26:47 +00:00
2021-01-01 13:47:53 +01:00
## Setting up the Reverse Proxy
2020-08-12 21:17:53 +02:00
2021-01-01 13:47:53 +01:00
This depends on whether you use Apache, Nginx or another web server.
### Apache
Create `/etc/apache2/sites-enabled/050-conduit.conf` and copy-and-paste this:
2021-04-15 23:08:13 +02:00
2021-08-17 14:44:53 +02:00
```apache
2021-01-01 13:47:53 +01:00
Listen 8448
< VirtualHost *:443 * :8448 >
ServerName your.server.name # EDIT THIS
2020-08-12 21:17:53 +02:00
AllowEncodedSlashes NoDecode
2021-04-23 15:27:35 -03:00
ProxyPass /_matrix/ http://127.0.0.1:6167/_matrix/ nocanon
ProxyPassReverse /_matrix/ http://127.0.0.1:6167/_matrix/
2020-08-12 21:17:53 +02:00
< / VirtualHost >
```
2021-01-01 13:47:53 +01:00
**You need to make some edits again.** When you are done, run
2021-04-15 23:08:13 +02:00
2020-08-12 21:17:53 +02:00
```bash
2022-02-06 17:48:06 +01:00
sudo systemctl reload apache2
2020-08-12 21:17:53 +02:00
```
2021-01-01 13:47:53 +01:00
### Nginx
2022-02-06 17:48:06 +01:00
If you use Nginx and not Apache, add the following server section inside the `http` section of `/etc/nginx/nginx.conf`
2021-04-15 23:08:13 +02:00
2021-08-17 14:44:53 +02:00
```nginx
2021-01-01 13:47:53 +01:00
server {
2021-04-23 15:27:35 -03:00
listen 443 ssl http2;
listen [::]:443 ssl http2;
listen 8448 ssl http2;
listen [::]:8448 ssl http2;
2021-01-01 13:47:53 +01:00
server_name your.server.name; # EDIT THIS
2021-04-23 15:27:35 -03:00
merge_slashes off;
2021-01-01 13:47:53 +01:00
location /_matrix/ {
2021-04-23 15:27:35 -03:00
proxy_pass http://127.0.0.1:6167$request_uri;
proxy_set_header Host $http_host;
proxy_buffering off;
2021-01-01 13:47:53 +01:00
}
2021-04-23 15:27:35 -03:00
ssl_certificate /etc/letsencrypt/live/your.server.name/fullchain.pem; # EDIT THIS
ssl_certificate_key /etc/letsencrypt/live/your.server.name/privkey.pem; # EDIT THIS
ssl_trusted_certificate /etc/letsencrypt/live/your.server.name/chain.pem; # EDIT THIS
include /etc/letsencrypt/options-ssl-nginx.conf;
2021-01-01 13:47:53 +01:00
}
```
2021-11-21 17:34:08 +00:00
2021-01-01 13:47:53 +01:00
**You need to make some edits again.** When you are done, run
2021-04-15 23:08:13 +02:00
2021-01-01 13:47:53 +01:00
```bash
2022-02-06 17:48:06 +01:00
sudo systemctl reload nginx
2021-01-01 13:47:53 +01:00
```
2020-08-12 21:17:53 +02:00
## SSL Certificate
2021-01-01 13:47:53 +01:00
The easiest way to get an SSL certificate, if you don't have one already, is to install `certbot` and run this:
2021-04-15 23:08:13 +02:00
2020-08-12 21:17:53 +02:00
```bash
2022-02-06 17:48:06 +01:00
sudo certbot -d your.server.name
2020-08-12 21:17:53 +02:00
```
## You're done!
2020-10-20 14:18:20 +02:00
Now you can start Conduit with:
2021-04-15 23:08:13 +02:00
2020-08-12 21:17:53 +02:00
```bash
2022-02-06 17:48:06 +01:00
sudo systemctl start conduit
2020-08-12 21:17:53 +02:00
```
2020-10-20 14:18:20 +02:00
Set it to start automatically when your system boots with:
2021-04-15 23:08:13 +02:00
2020-08-12 21:17:53 +02:00
```bash
2022-02-06 17:48:06 +01:00
sudo systemctl enable conduit
2020-08-12 21:17:53 +02:00
```
2021-05-22 13:39:31 +02:00
2021-09-01 13:09:24 +02:00
## How do I know it works?
You can open < https: / / app . element . io > , enter your homeserver and try to register.
You can also use these commands as a quick health check.
```bash
2022-02-06 17:48:06 +01:00
curl https://your.server.name/_matrix/client/versions
curl https://your.server.name:8448/_matrix/client/versions
2021-09-01 13:09:24 +02:00
```
2022-02-04 17:57:59 +01:00
- To check if your server can talk with other homeservers, you can use the [Matrix Federation Tester ](https://federationtester.matrix.org/ )
2022-02-06 17:48:06 +01:00
- If you want to set up an Appservice, take a look at the [Appservice Guide ](../appservices.md ).