2019-03-14 14:00:34 +00:00
# Install
2019-11-17 17:11:33 +00:00
## Pre-requisites
2019-03-14 14:00:34 +00:00
2019-11-17 17:11:33 +00:00
* A Linux machine with **root access**
* A **domain name** (or subdomain) for the Mobilizon server, e.g. `example.net`
* An **SMTP server** to deliver emails
2019-03-14 14:00:34 +00:00
2019-11-17 17:11:33 +00:00
!!! tip
You can also install Mobilizon [with Docker ](docker.md ).
2019-03-14 14:00:34 +00:00
2019-11-17 17:11:33 +00:00
## Dependencies
2019-03-14 14:00:34 +00:00
2019-11-17 17:11:33 +00:00
Mobilizon requires Elixir, NodeJS and PostgreSQL among other things.
Installing dependencies depends on the system you're using. Follow the steps of the [dependencies guide ](dependencies.md ).
2019-03-14 14:00:34 +00:00
2019-11-17 17:11:33 +00:00
## Setup
2019-03-14 14:00:34 +00:00
2019-11-17 17:11:33 +00:00
We're going to use a dedicated `mobilizon` user with `/home/mobilizon` home:
2019-03-14 14:00:34 +00:00
```bash
2019-11-17 17:11:33 +00:00
sudo adduser --disabled-login mobilizon
2019-03-14 14:00:34 +00:00
```
2019-11-17 17:11:33 +00:00
!!! tip
On FreeBSD
``` bash
sudo pw useradd -n mobilizon -d /home/mobilizon -s /usr/local/bin/bash -m
sudo passwd mobilizon
```
2019-03-14 14:00:34 +00:00
2019-11-17 17:11:33 +00:00
Then let's connect as this user:
2019-03-14 14:00:34 +00:00
```bash
sudo -i -u mobilizon
```
2019-11-17 17:11:33 +00:00
Let's start by cloning the repository in a directory named `live` :
2019-03-14 14:00:34 +00:00
```bash
git clone https://framagit.org/framasoft/mobilizon live & & cd live
```
2019-11-17 17:11:33 +00:00
## Installing dependencies
2019-03-14 14:00:34 +00:00
2019-05-19 09:38:09 +00:00
Install Elixir dependencies
2019-03-14 14:00:34 +00:00
```bash
mix deps.get
```
2019-11-17 17:11:33 +00:00
Then compile these dependencies and Mobilizon (this can take a few minutes)
2019-03-14 14:00:34 +00:00
```bash
2019-11-17 17:11:33 +00:00
mix compile
2019-03-14 14:00:34 +00:00
```
Go into the `js/` directory
```bash
2019-05-19 09:38:09 +00:00
cd js
2019-03-14 14:00:34 +00:00
```
2019-05-19 09:38:09 +00:00
2019-03-14 14:00:34 +00:00
and install the Javascript dependencies
2019-05-19 09:38:09 +00:00
2019-03-14 14:00:34 +00:00
```bash
2019-04-10 15:30:18 +00:00
yarn install
2019-03-14 14:00:34 +00:00
```
2019-11-17 17:11:33 +00:00
Finally, we can build the front-end (this can take a few seconds)
2019-03-14 14:00:34 +00:00
```bash
2019-04-10 15:30:18 +00:00
yarn run build
2019-03-14 14:00:34 +00:00
```
2019-05-19 09:38:09 +00:00
2019-11-17 17:11:33 +00:00
Let's go back to the main directory
```bash
cd ../
```
## Configuration
Mobilizon provides a command line tool to generate configuration
```bash
mix mobilizon.instance gen
```
This will ask you questions about your instance and generate a `.env.prod` file.
### Migration
Run database migrations: `mix ecto.migrate` . You will have to do this again after most updates.
!!! tip
If some migrations fail, it probably means you're not using a recent enough version of PostgreSQL, or that you haven't installed the required extensions.
2019-03-14 14:00:34 +00:00
## Services
### Systemd
2019-05-19 09:38:09 +00:00
Copy the `support/systemd/mobilizon.service` to `/etc/systemd/system` .
2019-03-14 14:00:34 +00:00
```bash
sudo cp support/systemd/mobilizon.service /etc/systemd/system/
```
Reload Systemd to detect your new file
```bash
sudo systemctl daemon-reload
```
2019-05-19 09:38:09 +00:00
2019-03-14 14:00:34 +00:00
And enable the service
```bash
systemctl enable --now mobilizon.service
```
2019-05-19 09:38:09 +00:00
It will run Mobilizon and enable startup on boot. You can follow the logs with
2019-03-14 14:00:34 +00:00
```bash
sudo journalctl -fu mobilizon.service
```
2019-10-11 15:03:18 +00:00
2019-11-17 17:11:33 +00:00
The Mobilizon server runs on port 4000 on the local interface only, so you need to add a reverse-proxy.
2019-10-11 15:03:18 +00:00
## Reverse proxy
### Nginx
Copy the file from `support/nginx/mobilizon.conf` to `/etc/nginx/sites-available` .
```bash
sudo cp support/nginx/mobilizon.conf /etc/nginx/sites-available
```
Then symlink the file into the `/etc/nginx/sites-enabled` directory.
```bash
sudo ln -s /etc/nginx/sites-available/mobilizon.conf /etc/nginx/sites-enabled/
```
Edit the file `/etc/nginx/sites-available` and adapt it to your own configuration.
2019-11-17 17:11:33 +00:00
Test the configuration with `sudo nginx -t` and reload nginx with `systemctl reload nginx` .