Diferencia entre revisiones de «Etherpad»

De Wiki Castanedo.es
Ir a la navegación Ir a la búsqueda
(Correcciones)
(Configuración etherpad)
Línea 2: Línea 2:
 
Se va a instalar etherpad 1.8.7 cuyos requisitos mínimos son:
 
Se va a instalar etherpad 1.8.7 cuyos requisitos mínimos son:
 
* nodejs >= 10.13.0
 
* nodejs >= 10.13.0
 +
* Nginx (opcional): servidor web para usar como frontal (reverse proxy).
 +
* MariaDB (opcional): base de datos para almacenar la información (mariadb-server).
  
 
== Usuario root ==
 
== Usuario root ==
Línea 214: Línea 216:
 
=== Cambiar título de la Wiki ===
 
=== Cambiar título de la Wiki ===
 
Remplazar el tag "title":
 
Remplazar el tag "title":
<syntaxhighlight lang="Bash">"title": "Castanedo Etherpad",</syntaxhighlight>
+
<syntaxhighlight lang="JSON">"title": "Castanedo Etherpad",</syntaxhighlight>
  
 
=== Personalizar el favicon ===
 
=== Personalizar el favicon ===
 
Subir al servidor el nuevo icono y actualizar la ruta en el tag "favicon":
 
Subir al servidor el nuevo icono y actualizar la ruta en el tag "favicon":
<syntaxhighlight lang="Bash">"favicon": "favicon.ico",</syntaxhighlight>
+
<syntaxhighlight lang="JSON">"favicon": "favicon.ico",</syntaxhighlight>
  
 
=== Personalizar skin ===
 
=== Personalizar skin ===
 
Existen dos temas por defecto en Etherpad: "no-skin" y "colibris" (por defecto).
 
Existen dos temas por defecto en Etherpad: "no-skin" y "colibris" (por defecto).
<syntaxhighlight lang="Bash">"skinName": "colibris",</syntaxhighlight>
+
<syntaxhighlight lang="JSON">"skinName": "colibris",</syntaxhighlight>
  
 
=== Personalizar colores (skinVariants) ===
 
=== Personalizar colores (skinVariants) ===
 
La opción "skinVariants" permite cambiar los posibles colores base del skin (por defecto colores claros).
 
La opción "skinVariants" permite cambiar los posibles colores base del skin (por defecto colores claros).
 
Para establecer un color oscuro:
 
Para establecer un color oscuro:
<syntaxhighlight lang="Bash">"skinVariants": "super-dark-toolbar super-dark-background dark-editor",</syntaxhighlight>
+
<syntaxhighlight lang="JSON">"skinVariants": "super-dark-toolbar super-dark-background dark-editor",</syntaxhighlight>
  
 
Para ver todas las posibilidades introduzca la siguiente URL "http://wwww.ejemplo.com/p/test#skinvariantsbuilder" y cambie la variable con los valores que escoja en la página.
 
Para ver todas las posibilidades introduzca la siguiente URL "http://wwww.ejemplo.com/p/test#skinvariantsbuilder" y cambie la variable con los valores que escoja en la página.
Línea 235: Línea 237:
  
 
* '''IP Binding:''' como es este ejemplo estamos accediendo a Etherpad a través del servidor web nginx como frontal, vamos a limitar la conexiones a la dirección del servidor web (al estar en la misma máquina: 127.0.0.1).
 
* '''IP Binding:''' como es este ejemplo estamos accediendo a Etherpad a través del servidor web nginx como frontal, vamos a limitar la conexiones a la dirección del servidor web (al estar en la misma máquina: 127.0.0.1).
<syntaxhighlight lang="C">
+
<syntaxhighlight lang="JSON">
 
// Sockets TCP/IP (Con IP Binding)
 
// Sockets TCP/IP (Con IP Binding)
 
"ip": "127.0.0.1",
 
"ip": "127.0.0.1",
Línea 242: Línea 244:
  
 
* '''Sockets UNIX''' al estar en la misma máquina podríamos usar también Sockets UNIX (en vez de sockets TCP/IP).
 
* '''Sockets UNIX''' al estar en la misma máquina podríamos usar también Sockets UNIX (en vez de sockets TCP/IP).
<syntaxhighlight lang="C">
+
<syntaxhighlight lang="JSON">
 
// Sockets UNIX
 
// Sockets UNIX
 
"ip": "",
 
"ip": "",
Línea 252: Línea 254:
 
Se puede modificar el idioma por defecto de Etherpad.
 
Se puede modificar el idioma por defecto de Etherpad.
 
Para español de España:
 
Para español de España:
<syntaxhighlight lang="Bash"></syntaxhighlight>
+
<syntaxhighlight lang="JSON">"lang": "es-es"</syntaxhighlight>
 +
 
 +
=== Base de datos MariaDB ===
 +
Etherpad soporta las bases de datos: PostgreSQL, SQLite, MySQL/MariaDB y DirtyDB (esta última es por defecto).
 +
'''Importante:''' DirtyDB no se recomienda en entornos productivos.
 +
Por eso se va a cambiar a MariaDB.
 +
 
 +
* Conectar a la base de datos (usuario root)
 +
 
 +
<syntaxhighligth lang="Bash">mariadb</syntaxhighligth>
 +
 
 +
* Crear base de datos: "etherpad_db"
 +
 
 +
<syntaxhighligth lang="SQL">CREATE DATABASE 'etherpad_db';</syntaxhighligth>
 +
 
 +
* Crear usuario: "etherpad" (cambiar contraseña)
 +
 
 +
<syntaxhighligth lang="SQL">CREATE USER 'etherpad'@'localhost'  identified by 'CONTRASEÑA';</syntaxhighligth>
 +
 
 +
* Establecer permisos
 +
 
 +
<syntaxhighligth lang="SQL">GRANT CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE ON `etherpad_db`.* TO 'etherpad'@'localhost';</syntaxhighligth>
 +
 
 +
* Aplicar y salir de MariaDB
 +
 
 +
<syntaxhighligth lang="SQL">
 +
FLUSH PRIVILEGES;
 +
quit;
 +
</syntaxhighligth>
 +
 
 +
* Editar la cadena de conexión (en Etherpad: settings.json)
 +
 
 +
<syntaxhighlight lang="JSON">
 +
"dbType" : "mysql",
 +
  "dbSettings" : {
 +
    "user":    "etherpad",
 +
    "host":    "localhost",
 +
    "port":    3306,
 +
    "password": "CONTRASEÑA",
 +
    "database": "etherpad_db",
 +
    "charset":  "utf8mb4"
 +
  },
 +
</syntaxhighlight>
  
 
=== Aplicar cambios ===
 
=== Aplicar cambios ===

Revisión del 11:41 8 ene 2021

Requisitos

Se va a instalar etherpad 1.8.7 cuyos requisitos mínimos son:

  • nodejs >= 10.13.0
  • Nginx (opcional): servidor web para usar como frontal (reverse proxy).
  • MariaDB (opcional): base de datos para almacenar la información (mariadb-server).

Usuario root

Todos los comandos se ejecutarán como root, a menos que se especifique lo contrario.

sudo -i

Ubuntu Server

Se va a instalar en un servidor: Ubuntu Server 20.04 TLS.

Instalación de requisitos

  • Instalación NodeJS
apt-get install nodejs npm

Requisitos en el OS

Se va a crear el usuario y el grupo "etherpad" para ejecutar etherpad.

groupadd -r etherpad
useradd -r -d /home/etherpad -m -g etherpad -s /bin/bash etherpad

Instalación de Etherpad 1.8.7

  • Descarga de Etherpad 1.8.7
cd /opt
curl -OL "https://github.com/ether/etherpad-lite/archive/1.8.7.tar.gz"
  • Compresión de Etherpad
tar -xzvf 1.8.7.tar.gz -C /opt
  • Establecimiento de permisos
chown -R etherpad:etherpad /opt/etherpad-lite-1.8.7
  • Instalación de dependencias de Etherpad
sudo -i -u etherpad /opt/etherpad-lite-1.8.7/bin/installDeps.sh

Añadir extensiones para Etherpad

Se añaden las siguientes extensiones:

npm install ep_headings2 ep_markdown ep_comments_page ep_align ep_font_color ep_webrtc ep_embedded_hyperlinks2

Etherpad con servicio (SystemD)

Se va a configurar Etherpad para que arranque con es OS.

  • Crear el fichero "/etc/systemd/system/etherpad.service"
[Unit]
Description=Etherpad-lite, the collaborative editor.
After=syslog.target network.target

[Service]
Type=simple
User=etherpad
Group=etherpad
WorkingDirectory=/opt/etherpad-lite-1.8.7
Environment=NODE_ENV=production
ExecStart=/usr/bin/nodejs --experimental-worker /opt/etherpad-lite-1.8.7/src/node/server.js
# use mysql plus a complete settings.json to avoid Service hold-off time over, scheduling restart.
Restart=always

[Install]
WantedBy=multi-user.target
  • Recargar demonios
systemctl daemon-reload
  • Arrancar Etherpad
systemctl start etherpad.service
  • Habilitar Etherpad durante el arranque
systemctl enable etherpad.service
  • Comprobar que Etherpad ha arrancado
systemctl status etherpad.service

Usar nginx como frontal

Etherpad tiene su propio servidor web que, por defecto, escucha en el puerto 9001/tcp. Se va a configurar nginx para que funcione como frontal y redireccione al servidor web de Etherpad (reverse proxy).

  • Crear y editar el fichero: "/etc/nginx/sites-available/etherpad"
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name localhost;
        return 301 https://$host$request_uri;
}

server {
        listen 443 ssl http2 default_server;
        listen [::]:443 ssl http2 default_server;
        ssl_certificate /etc/nginx/ssl/etherpad.crt;
        ssl_certificate_key /etc/nginx/ssl/etherpad.key;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.php;

        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                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;
        }

        # pass PHP scripts to FastCGI server
        #
        #location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
        #       #fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        #       fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       #fastcgi_pass 127.0.0.1:9000;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}

map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
}
  • Habilitar configuración
ln -s /etc/nginx/sites-available/etherpad /etc/nginx/sites-enabled/etherpad
  • Recargar configuración de nginx
systemctl reload nginx

Configuración y personalización de Etherpad

Todos estos cambios se realizan editando el fichero "/opt/etherpad-lite-1.8.7/settings.json".

Recomendamos realizar primero un backup del fichero original:

cp -a /opt/etherpad-lite-1.8.7/settings.json /opt/etherpad-lite-1.8.7/settings.json.orig

Cambiar título de la Wiki

Remplazar el tag "title":

"title": "Castanedo Etherpad",

Personalizar el favicon

Subir al servidor el nuevo icono y actualizar la ruta en el tag "favicon":

"favicon": "favicon.ico",

Personalizar skin

Existen dos temas por defecto en Etherpad: "no-skin" y "colibris" (por defecto).

"skinName": "colibris",

Personalizar colores (skinVariants)

La opción "skinVariants" permite cambiar los posibles colores base del skin (por defecto colores claros). Para establecer un color oscuro:

"skinVariants": "super-dark-toolbar super-dark-background dark-editor",

Para ver todas las posibilidades introduzca la siguiente URL "http://wwww.ejemplo.com/p/test#skinvariantsbuilder" y cambie la variable con los valores que escoja en la página.

Configuración IP y puerto TCP (IP Binding)

Se puede configurar el puerto TCP que usa Etherpad (por defecto: 9001) y las direcciones IP autorizadas (por defecto todas: 0.0.0.0).

  • IP Binding: como es este ejemplo estamos accediendo a Etherpad a través del servidor web nginx como frontal, vamos a limitar la conexiones a la dirección del servidor web (al estar en la misma máquina: 127.0.0.1).
// Sockets TCP/IP (Con IP Binding)
"ip": "127.0.0.1",
"port": 9001,
  • Sockets UNIX al estar en la misma máquina podríamos usar también Sockets UNIX (en vez de sockets TCP/IP).
// Sockets UNIX
"ip": "",
"port": "/opt/etherpad-lite-1.8.7/etherpad.socket",

En este caso además habría modificar el "reverse proxy" de nginx para que usase el Socket UNIX de Etherpad.

Idioma

Se puede modificar el idioma por defecto de Etherpad. Para español de España:

"lang": "es-es"

Base de datos MariaDB

Etherpad soporta las bases de datos: PostgreSQL, SQLite, MySQL/MariaDB y DirtyDB (esta última es por defecto). Importante: DirtyDB no se recomienda en entornos productivos. Por eso se va a cambiar a MariaDB.

  • Conectar a la base de datos (usuario root)

<syntaxhighligth lang="Bash">mariadb</syntaxhighligth>

  • Crear base de datos: "etherpad_db"

<syntaxhighligth lang="SQL">CREATE DATABASE 'etherpad_db';</syntaxhighligth>

  • Crear usuario: "etherpad" (cambiar contraseña)

<syntaxhighligth lang="SQL">CREATE USER 'etherpad'@'localhost' identified by 'CONTRASEÑA';</syntaxhighligth>

  • Establecer permisos

<syntaxhighligth lang="SQL">GRANT CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE ON `etherpad_db`.* TO 'etherpad'@'localhost';</syntaxhighligth>

  • Aplicar y salir de MariaDB

<syntaxhighligth lang="SQL"> FLUSH PRIVILEGES; quit; </syntaxhighligth>

  • Editar la cadena de conexión (en Etherpad: settings.json)
"dbType" : "mysql",
  "dbSettings" : {
    "user":     "etherpad",
    "host":     "localhost",
    "port":     3306,
    "password": "CONTRASEÑA",
    "database": "etherpad_db",
    "charset":  "utf8mb4"
  },

Aplicar cambios

Para que los cambios sean efectivos hay que reiniciar Etherpad.

systemctl restart etherpad

Referencias