MÀJ HowtoEtherpad

This commit is contained in:
Mathieu Gauthier-Pilote 2023-02-02 13:45:14 -05:00
parent 7638c94988
commit d457169b75

View file

@ -1,141 +1,213 @@
**Cette page a été importée automatiquement de notre ancien wiki mais n'a pas encore été révisée.**
---
categories: web webapp
title: Howto Etherpad
...
# HowtoEtherpad
* Documentation : <https://etherpad.org/doc/v1.8.18/>
* Code : <https://github.com/ether/etherpad-lite>
* Licence : Apache-2.0
* Langage : Javascript
* Ansible : à venir
Etherpad est un éditeur texte collaboratif en ligne.
On utilise désormais la version Etherpad-Lite.
* <http://etherpad.org/>
* <https://github.com/ether/etherpad-lite/>
* Statut du package Debian officiel : <http://bugs.debian.org/576998>
[Etherpad](https://github.com/ether/etherpad-lite) est une application web de rédaction collaborative en temps réel développée en node.js.
## Installation
Debian Jessie :
Nous installons la version **1.8.18** sous **Debian 11 (Bullseye)** en mode manuel. (Il y a aussi un mode d'installation pour [Docker](https://github.com/ether/etherpad-lite/blob/develop/doc/docker.md).)
Etherpad s'appuie sur [NodeJS](HowtoNodeJS) et peut être configurée avec différents SGBD ([MariaDB/MySQL](HowtoMySQL), PostgreSQL, SQLite) et proxy web ([Nginx](HowtoNginx), Apache, HAProxy, Varnish, etc). Dans la présente documentation, nous montrons comment faire avec MariaDB et Nginx.
On installe les dépendances de la manière suivante :
~~~
# apt install gzip git curl python libssl-dev pkg-config build-essential
# apt install nodejs npm
# adduser --system --home=/home/etherpad-lite --group etherpad-lite
$ git clone git://github.com/ether/etherpad-lite.git
# vim /etc/systemd/system/etherpad-lite.service
[Unit]
Description=etherpad-lite (real-time collaborative document editing)
After=syslog.target network.target
[Service]
Type=simple
User=etherpad-lite
Group=etherpad-lite
ExecStart=/home/etherpad-lite/etherpad-lite/bin/run.sh
[Install]
WantedBy=multi-user.target
# systemctl enable etherpad-lite
Created symlink from /etc/systemd/system/multi-user.target.wants/etherpad-lite.service to /etc/systemd/system/etherpad-lite.service.
# systemctl start etherpad-lite
# apt install apt-transport-https mariadb-server nginx git wget
# echo "deb https://deb.nodesource.com/node_18.x $(awk -F= '/VERSION_CODENAME/{print $2}' /etc/os-release) main" > /etc/apt/sources.list.d/nodesource.list
# wget https://deb.nodesource.com/gpgkey/nodesource.gpg.key -O /etc/apt/trusted.gpg.d/nodesource.asc
# chmod 644 /etc/apt/trusted.gpg.d/nodesource.asc
# apt update && apt install nodejs
~~~
Voir <https://github.com/ether/etherpad-lite/wiki/How-to-deploy-Etherpad-Lite-as-a-service>
### Compte UNIX
Note : les scripts bin/run.sh et bin/installDeps.sh utilisent la commande "node" et non "nodejs", il peut donc être nécessaire de modifier ou créer un alias node=nodejs
### Installation (deprecated)
En installant nodejs depuis les sources.
Suivre les infos sur : <https://github.com/Pita/etherpad-lite/blob/master/README.md>
Créer un compte UNIX *etherpad* :
~~~
# aptitude install gzip git-core curl python libssl-dev build-essential
# apt-get build-dep nodejs=0.6.8~dfsg1-1
$ wget <http://nodejs.org/dist/v0.6.10/node-v0.6.10.tar.gz>
$ tar xvf node-v0.6.10.tar.gz
$ cd node-v0.6.10
$ ./configure && make
# make install
$ git clone <https://github.com/Pita/etherpad-lite.git>
$ cd ../etherpad-lite/
$ ./bin/installDeps.sh
$ vim settings.json
$ ./bin/run.sh
# adduser --disabled-login --gecos 'etherpad App' etherpad
~~~
Lancer bin/run.sh
### MariaDB
## Configuration
Cela ce passe dans _settings.json_
### Stockage des données
Par défaut, Etherpad utilise DirtyDB (un fichier à plat) mais on peut utiliser sqlite ou MySQL.
Pour DirtyDB :
Créer (par exemple) la base de données *etherpad* et l'utilisateur Mariadb du même nom :
~~~
"dbType" : "dirty",
# mysqladmin create etherpad;
# mysql
MariaDB [(none)]> GRANT ALL PRIVILEGES ON etherpad.* TO 'etherpad'@'localhost' IDENTIFIED BY 'Un-vrai-mot-de-passe';
~~~
> **Note** : Pensez à conserver le mot de passe pour la suite.
### Etherpad
On clone le dépôt et on bâtit l'application :
~~~
# sudo -iu etherpad
$ git clone https://github.com/ether/etherpad-lite.git
$ cd etherpad-lite/
$ git checkout 1.8.18
$ src/bin/run.sh
~~~
> Le script run.sh s'occuper d'installer et de configurer tout et lance même etherpad en mode devel sur http://0.0.0.0:9001
> Une fois confirmé qu'Etherpad fonctionne, vous pouvez quitter en appuyant sur `Ctrl + C` sur le clavier.
On édite le fichier `settings.json` généré par `src/bin/run.sh`. Vous devrez nécessairement modifier au minimum les valeurs des variables relatives à la base de données et il est recommandé de faire passer la valeur de la variable `ip` de `0.0.0.0` à `127.0.0.1`.
~~~
{
"ip": "127.0.0.1",
"dbType" : "mysql",
"dbSettings" : {
"filename" : "var/dirty.db"
},
~~~
Pour MySQL utiliser MySQL :
~~~
mysql> create database etherpad;
mysql> grant CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE on `etherpad`.* to 'etherpad'@'localhost' identified by '<password>';
~~~
puis :
~~~
"dbType" : "mysql",
"dbSettings" : {
"user" : "etherpad",
"host" : "127.0.0.1",
"password": "<password>",
"database": "etherpad"
},
~~~
puis :
~~~
$ sh bin/installDeps.sh
# systemctl restart etherpad-lite
mysql> show tables
+--------------------+
| Tables_in_etherpad |
+--------------------+
| store |
+--------------------+
mysql> ALTER DATABASE `etherpad` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
mysql> ALTER TABLE `store` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
~~~
Voir <https://github.com/ether/etherpad-lite/wiki/How-to-use-Etherpad-Lite-with-MySQL>
### Reverse Proxy
Avec Nginx :
~~~
server {
listen 80;
server_name pad.example.com;
location / {
proxy_pass <http://127.0.0.1:9001/;>
proxy_set_header Host $host;
proxy_pass_header Server;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_<http_version> 1.1;
}
"user": "etherpad",
"port": "/run/mysqld/mysqld.sock",
"password": "Un-vrai-mot-de-passe",
"database": "etherpad",
"charset": "utf8mb4"
},
}
~~~
Voir <https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy>
Pour ajuster plus de paramètres, on peut s'appuyer sur la documentation très claire contenue dans le fichier `settings.json.template`.
### Unité systemd
Pour lancer l'application au démarrage du serveur, on met le texte suivant dans le nouveau fichier `/etc/systemd/system/etherpad.service`
~~~
[Unit]
Description=Etherpad - open source online editor for real-time collaborative editing.
Documentation=https://etherpad.org/doc/v1.8.18/
After=network.target
After=mariadb.service
[Service]
Type=simple
Environment=NODE_ENV=production
ExecStart=/usr/bin/node --experimental-worker /home/etherpad/etherpad-lite/node_modules/ep_etherpad-lite/node/server.js
Restart=always
User=etherpad
Group=etherpad
WorkingDirectory=/home/etherpad/etherpad-lite
[Install]
WantedBy=multi-user.target
~~~
On active et on démarre l'unité en question :
~~~
# systemctl enable etherpad.service
# systemctl start etherpad.service
~~~
### Nginx
Pour accéder à l'application depuis Internet, on place nginx devant, qui agira comme serveur mandataire (*proxy*).
Il faut mettre le texte suivant dans le nouveau fichier `/etc/nginx/sites-available/etherpad.conf` :
~~~
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name etherpad.evolix.org;
# Let's Encrypt
include /etc/nginx/snippets/letsencrypt.conf;
# Redirect all to https (port 443)
location / { return 301 https://$host$request_uri; }
}
server {
listen [::]:443 ssl http2;
listen 443 ssl http2;
server_name etherpad.evolix.org;
ssl_certificate /etc/letsencrypt/live/etherpad.evolix.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/etherpad.evolix.org/privkey.pem;
location / {
proxy_pass http://127.0.0.1:9001;
proxy_buffering off; # be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf
proxy_set_header Host $host;
proxy_pass_header Server;
# Note you might want to pass these headers etc too.
proxy_set_header X-Real-IP $remote_addr; # https://nginx.org/en/docs/http/ngx_http_proxy_module.html
proxy_set_header X-Forwarded-For $remote_addr; # EP logs to show the actual remote IP
proxy_set_header X-Forwarded-Proto $scheme; # for EP to set secure cookie flag when https is used
proxy_http_version 1.1; # recommended with keepalive connections
# WebSocket proxying - from https://nginx.org/en/docs/http/websocket.html
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
~~~
> **Note** : La partie SSL/TLS n'est pas développée. Vous pouvez par exemple générer et configurer un certificat [Let's Encrypt](HowtoLetsEncrypt) avec certbot. N'oubliez donc pas de modifier les directives `ssl_` dans le vhost.
On active le vhost, on vérifie sa syntaxe et si tout est beau on recharge la configuration de nginx :
~~~
# ln -s /etc/nginx/sites-available/etherpad.conf /etc/nginx/sites-enabled/etherpad.conf
# nginx -t
# systemctl reload nginx.service
~~~
## Mises à jour
Les mises à jour peuvent être récupérées comme ceci :
~~~
# systemctl stop etherpad.service
# sudo -iu etherpad
$ cd etherpad-lite
$ git fetch origin && git checkout <NOUV_VERSION>
$ src/bin/run.sh
$ (Ctrl + C)
$ exit
# systemctl start etherpad.service
~~~
> **Note** : Ces commandes ne sont parfois pas suffisantes. Vous devez systématiquement lire les [notes de versions](https://github.com/ether/etherpad-lite/releases).
## Configuration
Etherpad est configurable via le fichier `settings.json` ou des variables d'environnement.
Il y a +200 [plugins](https://static.etherpad.org/) disponibles, dont environ 80 sont officiels.
## Utilisation
On peut utiliser en principe n'importe quel navigateur Web moderne pour se connecter à Etherpad.
## FAQ
### À propos des logs
On accède à la journalisation des événements de l'application via journald :
~~~
# systemctl status etherpad.service
# journalctl --unit=etherpad --no-pager
~~~