diff --git a/HowtoMastodon.md b/HowtoMastodon.md index 1cd03b6d..e4162443 100644 --- a/HowtoMastodon.md +++ b/HowtoMastodon.md @@ -1,34 +1,28 @@ --- -categories: web +categories: web social title: Howto Mastodon ... * Documentation : -[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*. +[Mastodon](https://github.com/tootsuite/mastodon) est un réseau social libre et décentralisé, en alternative à _Twitter_. -# Installation -Nous installons la version **1.4.7** sous **Debian 8** (Jessie). +## Installation -Mastodon s'appuie sur Ruby, NodeJS, Yarn, Nginx, Redis et PostgreSQL. +Nous installons la version **1.4.7** sous **Debian 8 (Jessie)**. -## Dépendances +Mastodon s'appuie sur Ruby, [NodeJS](HowtoNodeJS), [Yarn](HowtoYarn), [Nginx](HowtoNginx), [Redis](HowtoRedis) et [PostgreSQL](HowtoPostgresql). -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 : +On peut installer 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. +> **Note** : Vous devez avoir les backports `jessie-backports` pour installer _ffmpeg_. -## Compte UNIX +### Compte UNIX Créer un compte UNIX *mastodon* : @@ -38,7 +32,39 @@ Créer un compte UNIX *mastodon* : > **Note** : Assurez-vous d'avoir `DIR_MODE=0750` dans `/etc/adduser.conf` pour créer le home en 750. -## PostgreSQL +### Ruby + +Mastodon nécessite une version très récente de Ruby (2.4.1), on le met en place via [rbenv](HowtoRails#cas-2-utilisation-avec-rbenv-unicorn) : + +~~~ +# 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 +~~~ + +### NodeJS et Yarn + +Mastodon nécessite une version très récentes de [NodeJS](HowtoNodeJS) et [Yarn](HowtoYarn) : + +~~~ +# echo "deb http://deb.nodesource.com/node_6.x jessie main" > /etc/apt/sources.list.d/nodesource.list +# wget https://deb.nodesource.com/gpgkey/nodesource.gpg.key -O -|apt-key add - + +# echo "deb http://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list +# wget https://dl.yarnpkg.com/debian/pubkey.gpg -O - | apt-key add - + +# apt update +# apt install nodejs yarn +~~~ + +### PostgreSQL Mastodon utilise [PostgreSQL](HowtoPostgreSQL). On utilise donc la version 9.4 de Debian Jessie : @@ -54,10 +80,9 @@ Création de l'utilisateur PostgreSQL : > **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*). +> **Note** : Pensez à conserver le mot de passe pour le mettre par la suite (ou pas si utilisation de l'authentification via _ident_). - -## Redis +### Redis Installation classique : @@ -66,38 +91,13 @@ Installation classique : ~~~ -## Mastodon +### Mastodon -### Installation - -Attention, si vous avez un `/home` en `noexec`, il faudra le passer en `exec` pour les processus Ruby et NPM. Au risque d'obtenir ce genre d'erreurs : - -~~~ -npm[2990]: Error: Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a supported C++11 compiler and reinstall the module 'uws'. -Failed at step EXEC spawning /home/mastodon/.rbenv/shims/bundle: Permission denied -~~~ - -#### rbenv - -Mastodon recommande d'utiliser rbenv avec Ruby 2.4.1. +On clone le repository et installe avec _bundle_ et _yarn_ : ~~~ # 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 -~~~ - -#### Mastodon - -~~~ $ cd mastodon $ git checkout v1.4.7 $ gem install bundler @@ -107,9 +107,14 @@ $ cp .env.production.sample .env.production $ bundle exec rake secret ~~~ -### Configuration +> Attention, si vous avez un `/home` en `noexec`, il faudra le passer en `exec` pour les processus Ruby et NPM. Au risque d'obtenir ce genre d'erreurs : +> +> ~~~ +> npm[2990]: Error: Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a > supported C++11 compiler and reinstall the module 'uws'. +> Failed at step EXEC spawning /home/mastodon/.rbenv/shims/bundle: Permission denied +> ~~~ -Éditer `.env.production` à votre convenance, voici un exemple : +On édite le fichier fichier `.env.production` à notre convenance, voici un exemple : ~~~ REDIS_HOST=127.0.0.1 @@ -123,9 +128,9 @@ DB_PORT=5432 LOCAL_DOMAIN=mastodon.example.com LOCAL_HTTPS=true -PAPERCLIP_SECRET=SECRET -SECRET_KEY_BASE=SECRET -OTP_SECRET=SECRET +PAPERCLIP_SECRET=PASSWORD +SECRET_KEY_BASE=PASSWORD +OTP_SECRET=PASSWORD EMAIL_DOMAIN_WHITELIST=example.com @@ -155,12 +160,11 @@ $ bundle exec rails assets:precompile $ chmod -R u=rwX,g=rwX,o=rX /home/mastodon/mastodon/public ~~~ - -## Unités systemd +### Unités systemd Unités systemd à mettre dans /etc/systemd/system -mastodon-web.service +`mastodon-web.service` ~~~ [Unit] @@ -181,7 +185,7 @@ Restart=always WantedBy=multi-user.target ~~~ -mastodon-sidekiq.service +`mastodon-sidekiq.service` ~~~ [Unit] @@ -202,7 +206,7 @@ Restart=always WantedBy=multi-user.target ~~~ -mastodon-streaming.service +`mastodon-streaming.service` ~~~ [Unit] @@ -223,21 +227,23 @@ Restart=always WantedBy=multi-user.target ~~~ +On active et on démarre les unités : + ~~~ # systemctl enable mastodon-{web,sidekiq,streaming} # systemctl start mastodon-{web,sidekiq,streaming} ~~~ -## Crontab +### Crontab ~~~ RAILS_ENV=production @daily cd /home/mastodon/mastodon && /home/mastodon/.rbenv/shims/bundle exec rake mastodon:daily > /dev/null ~~~ -## Nginx +### Nginx -On utilise Nginx : +On utilise [Nginx](Howtonginx) : ~~~ # apt install nginx-full @@ -337,9 +343,10 @@ server { } ~~~ -> **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. +> **Note** : La partie SSL/TLS n'est pas évoquée. À vous de faire le nécessaire avec un certificat [Let's Encrypt](HowtoLetsEncrypt) par exemple. N'oubliez donc pas de modifier les directives `ssl_` dans le vhost. -# Mises à jour + +## Mises à jour Le principe des mises à jour est basé sur un `git pull` et un `git checkout`. @@ -359,9 +366,27 @@ $ exit > **Note** : Ces commandes génériques ne sont parfois pas suffisantes. Pensez à lire les [notes de versions](https://github.com/tootsuite/mastodon/releases/). -# Divers / FAQ -## À propos des logs +## Configuration + +Pour restreindre l'inscription à certains domaines de messagerie : + +~~~ +EMAIL_DOMAIN_WHITELIST=example.com|example.org +~~~ + + +## Utilisation + +On peut utiliser différents clients : + +- L'interface web via un navigateur +- [Twidere](https://github.com/TwidereProject) sous Android ou iOS +- [Amaroq](https://itunes.apple.com/us/app/amaroq-for-mastodon/id1214116200) sous iOS + + +## FAQ + +### À propos des logs Mastodon n'a aucun fichier de logs. Les logs sont gérés via la sortie standard et vont donc dans journald. On consultera les logs avec `journalctl -u mastodon-SERVICE`. -