Premier jet de la doc.
This commit is contained in:
parent
ffe55eac14
commit
36dc204644
|
@ -0,0 +1,232 @@
|
|||
---
|
||||
categories: web
|
||||
title: Howto Mastodon
|
||||
...
|
||||
|
||||
* Documentation : <https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Production-guide.md>
|
||||
|
||||
[Mastodon](https://github.com/tootsuite/mastodon) est un réseau social libre et décentralisé. Mastodon ressemble sous certains aspects au logiciel propriétaire *Twitter*.
|
||||
|
||||
# Installation
|
||||
|
||||
Nous installons la version **1.4.1** sous **Debian 8** (Jessie).
|
||||
|
||||
Mastodon s'appuie sur Ruby, NodeJS, Yarn, Nginx, Redis et PostgreSQL.
|
||||
|
||||
## Dépendances
|
||||
|
||||
Mastodon nécessite des versions très récentes de Ruby et NodeJS. Ruby sera mis en place via rbenv.
|
||||
|
||||
Pour NodeJS, il faut l'installer [ainsi](https://wiki.evolix.org/HowtoNodeJS).
|
||||
Il faut aussi installer [Yarn](https://wiki.evolix.org/HowtoYarn).
|
||||
|
||||
On peut ainsi installer toutes les dépendances pour Mastodon :
|
||||
|
||||
~~~
|
||||
# apt install nodejs yarn imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git curl g++ libprotobuf-dev protobuf-compiler pkg-config build-essential libreadline-dev
|
||||
~~~
|
||||
|
||||
> **Note** : Vous devez avoir les backports `jessie-backports` pour installer ffmpeg.
|
||||
|
||||
## Compte UNIX
|
||||
|
||||
Créer un compte UNIX *mastodon* :
|
||||
|
||||
~~~
|
||||
# adduser --disabled-login --gecos 'Mastodon App' mastodon
|
||||
~~~
|
||||
|
||||
> **Note** : Assurez-vous d'avoir `DIR_MODE=0750` dans `/etc/adduser.conf` pour créer le home en 750.
|
||||
|
||||
## PostgreSQL
|
||||
|
||||
Mastodon utilise [PostgreSQL](HowtoPostgreSQL). On utilise donc la version 9.4 de Debian Jessie :
|
||||
|
||||
~~~
|
||||
# apt install postgresql postgresql-client libpq-dev postgresql-contrib
|
||||
~~~
|
||||
|
||||
Création de l'utilisateur PostgreSQL :
|
||||
|
||||
~~~
|
||||
# sudo -u postgres createuser mastodon -d -P -R
|
||||
~~~
|
||||
|
||||
> **Note** : On donne les droits CREATEDB car Mastodon doit faire un DROP DATABASE puis CREATE DATABASE lors de l'installation…
|
||||
|
||||
> **Note** : Pensez à conserver le mot de passe pour le mettre par la suite (ou pas si utilisation d'authenitifcation *ident*).
|
||||
|
||||
|
||||
## Redis
|
||||
|
||||
Installation classique :
|
||||
|
||||
~~~
|
||||
# apt install redis-server
|
||||
~~~
|
||||
|
||||
|
||||
## Mastodon
|
||||
|
||||
### Installation
|
||||
|
||||
~~~
|
||||
# sudo -iu mastodon
|
||||
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
||||
$ cd ~/.rbenv && src/configure && make -C src
|
||||
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
|
||||
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
|
||||
$ echo 'export RAILS_ENV="production"' >> ~/.bash_profile
|
||||
$ source ~/.bash_profile
|
||||
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
||||
$ cd
|
||||
$ TMPDIR=~/tmp MAKE_OPTS=-j$(nproc) rbenv install 2.4.1
|
||||
$ git clone https://github.com/tootsuite/mastodon.git
|
||||
$ cd mastodon
|
||||
$ git checkout v1.4.1
|
||||
$ gem install bundler
|
||||
$ bundle install --deployment --without development test
|
||||
$ yarn install --pure-lockfile
|
||||
$ cp .env.production.sample .env.production
|
||||
$ bundle exec rake secret
|
||||
~~~
|
||||
|
||||
### Configuration
|
||||
|
||||
Éditer `.env.production` à votre convenance, voici un exemple :
|
||||
|
||||
~~~
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PORT=6379
|
||||
DB_HOST=127.0.0.1
|
||||
DB_USER=mastodon
|
||||
DB_NAME=mastodon_production
|
||||
DB_PASS=PASSWORD
|
||||
DB_PORT=5432
|
||||
|
||||
LOCAL_DOMAIN=mastodon.example.com
|
||||
LOCAL_HTTPS=true
|
||||
|
||||
PAPERCLIP_SECRET=SECRET
|
||||
SECRET_KEY_BASE=SECRET
|
||||
OTP_SECRET=SECRET
|
||||
|
||||
EMAIL_DOMAIN_WHITELIST=example.com
|
||||
|
||||
DEFAULT_LOCALE=fr
|
||||
|
||||
SMTP_SERVER=127.0.0.1
|
||||
SMTP_PORT=25
|
||||
SMTP_LOGIN=
|
||||
SMTP_PASSWORD=
|
||||
SMTP_FROM_ADDRESS=mastodon@mastodon.example.com
|
||||
#SMTP_DOMAIN= # defaults to LOCAL_DOMAIN
|
||||
#SMTP_DELIVERY_METHOD=smtp # delivery method can also be sendmail
|
||||
SMTP_AUTH_METHOD=none
|
||||
SMTP_OPENSSL_VERIFY_MODE=none
|
||||
~~~
|
||||
|
||||
Initialisation de la base de données :
|
||||
|
||||
~~~
|
||||
$ bundle exec rails db:setup
|
||||
~~~
|
||||
|
||||
Compilation des assets :
|
||||
|
||||
~~~
|
||||
$ bundle exec rails assets:precompile
|
||||
~~~
|
||||
|
||||
|
||||
## Unités systemd
|
||||
|
||||
Unités systemd à mettre dans /etc/systemd/system
|
||||
|
||||
mastodon-web.service
|
||||
~~~
|
||||
[Unit]
|
||||
Description=mastodon-web
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=mastodon
|
||||
WorkingDirectory=/home/mastodon/mastodon
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="PORT=3000"
|
||||
ExecStart=/home/mastodon/.rbenv/shims/bundle exec puma -C config/puma.rb
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
~~~
|
||||
|
||||
mastodon-sidekiq.service
|
||||
~~~
|
||||
[Unit]
|
||||
Description=mastodon-sidekiq
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=mastodon
|
||||
WorkingDirectory=/home/mastodon/mastodon
|
||||
Environment="RAILS_ENV=production"
|
||||
Environment="DB_POOL=5"
|
||||
ExecStart=/home/mastodon/.rbenv/shims/bundle exec sidekiq -c 5 -q default -q mailers -q pull -q push
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
~~~
|
||||
|
||||
mastodon-streaming.service
|
||||
~~~
|
||||
[Unit]
|
||||
Description=mastodon-streaming
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=mastodon
|
||||
WorkingDirectory=/home/mastodon/mastodon
|
||||
Environment="NODE_ENV=production"
|
||||
Environment="PORT=4000"
|
||||
ExecStart=/usr/bin/npm run start
|
||||
TimeoutSec=15
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
~~~
|
||||
|
||||
~~~
|
||||
# systemctl enable mastodon-{web,sidekiq,streaming}
|
||||
# systemctl start mastodon-{web,sidekiq,streaming}
|
||||
~~~
|
||||
|
||||
## Crontab
|
||||
|
||||
~~~
|
||||
RAILS_ENV=production
|
||||
@daily cd /home/mastodon/mastodon && /home/mastodon/.rbenv/shims/bundle exec rake mastodon:daily > /dev/null
|
||||
~~~
|
||||
|
||||
## Nginx
|
||||
|
||||
On utilise Nginx :
|
||||
|
||||
~~~
|
||||
# apt install nginx
|
||||
~~~
|
||||
|
||||
> **Note** : La partie SSL/TLS n'est pas évoquée. À vous de faire le nécessaire avec un certificat Let's Encrypt par exemple. N'oubliez donc pas de modifier les directives `ssl_` dans le vhost.
|
||||
|
||||
# Mises à jour
|
||||
|
||||
Le principe des mises à jour est basé sur un `git pull` et un `git checkout`.
|
||||
|
||||
# Divers / FAQ
|
Loading…
Reference in New Issue