How to Install Etherpad-Lite on a Gandi Cloud Server

Etherpad is a collaborative real-time text editor, allowing several people to edit the same document at the same time.

We will describe below how to install the service and make it available quickly.

Note

This installation was carried out with the following tools:
  • Debian 10.3

  • Node.js 13.x

  • Etherpad 1.8.0

  • Nginx 1.14.2

Depending on your versions used, the steps below may vary

Step 1 : Installing dependencies and preparing the server

We assume here that you have already created your Cloud server.

Connect to your Cloud server via SSH:

$ ssh admin@1.2.3.4

And ensure your system packages are up to date:

$ su
# apt update
# apt upgrade

Then, install git, mariadb, and nginx:

# apt install git nginx mariadb-server

Next, install Node.js and npm:

# curl -sL https://deb.nodesource.com/setup_13.x | bash -
# apt install -y nodejs

It is also recommended to create a dedicated user to run Etherpad-lite:

# useradd -mU etherpad

The server is now configured, so let’s move on to creating the database.

Step 2 : Preparing the database

Etherpad-lite can work without a database in its default configuration, however this ability is intended for testing or specific use cases. In most cases, it is recommended to use a database, such as MySQL.

Create the database that will be used by Ehterpad-lite. Here we will name the database``db_etherpad``:

# mysql

MariaDB [(none)]> CREATE DATABASE db_etherpad;
Query OK, 1 row affected (0.001 sec)

Then, create the user who will connect to the database, and grant that user all privileges on the database:

MariaDB [(none)]> GRANT ALL privileges ON db_etherpad.* TO 'etherpad'@'localhost' IDENTIFIED BY 'MotDePasse';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> FLUSH privileges;
Query OK, 0 rows affected (0.001 sec)

Exit MySQL (MariaDB):

MariaDB [(none)]> \q
Bye

Now that the database is ready, we can install Etherpad-lite, and make it accessible at the address of your choice.

Step 3 : Installation and configuration of Etherpad-lite

Switch to the etherpad user :

# su - etherpad

And navigate to the home folder /home/etherpad for the user:

$ cd

Download the Etherpad-lite code using git:

$ git clone https://github.com/ether/etherpad-lite.git

Then run the run.sh script which installs the required dependencies automatically. The script needs to be run as root for this first run:

$ cd etherpad-lite
$ su -c bin/run.sh

When the script is finished, exit the script with Ctrl + C.

Then, change the environment variable of Node.js to specify production:

$ NODE_ENV=production
$ export NODE_ENV

Or, use this single-command:

$ export NODE_ENV=production

When the run.sh script was executed, some files were created and belong to the root user. These files are necessary for the proper functioning of Etherpad-lite, which we will execute with the etherpad user. For this reason, it is neccessary to redefine the ownership of all files to the etherpad user.

Return to the root user:

$ exit

And modify the file ownership:

# chown -R etherpad:etherpad /home/etherpad/etherpad-lite

You will now be able to edit the configuration file settings.json.

Switch back to the etherpad user:

# su - etherpad

And open the settings.json file with your favorite editor:

$ vim etherpad-lite/settings.json

To define the database created earlier, replace these lines:

"dbType": "dirty",
"dbSettings": {
  "filename": "var/dirty.db"
},

With this:

"dbType" : "mysql",
"dbSettings" : {
  "user":     "etherpad",
  "host":     "localhost",
  "port":     3306,
  "password": "MotDePasse",
  "database": "db_etherpad",
  "charset":  "utf8mb4"
},

In the same file, let’s take the opportunity to change the administrator credentials, which will be useful for you to login to the administration backend of Etherpad-lite:

"users": {
  "Administrator": {
      "password": "SOMEPASSWORD",
      "is_admin": true
      },
  },

Create a new etherpad-lite.service file in /etc/systemd/system/ with the following content:

[Unit]
Description=etherpad (collaborative editing of documents in real-time)
After=syslog.target network.target

[Service]
Type=simple
User=etherpad
Group=etherpad
Environment=NODE_ENV=production
ExecStart=/home/etherpad/etherpad-lite/bin/run.sh

[Installer]
WantedBy=multi-user.target

Run the following to activate the service at startup:

# systemctl daemon-reload
# systemctl enable etherpad-lite

And then start the service with:

# systemctl start etherpad-lite

If everything is in order, etherpad-lite will start correctly.

Your etherpad instance is now running and can be accessed at http://127.0.0.1:9001

Step 4 : Configure Nginx reverse-proxy to assign your domain or sub-domain to Etherpad

We assume here that you have an SSL certificate, so now we’ll configure nginx so that etherpad is accessible from your domain or sub-domain.

As root, open a new file for your site’s nginx configuration:

# vim /etc/nginx/sites-available/pad.yourdomain.conf

Include the following content in the configuration file. Make sure you replace “pad.yourdomain.com” with the domain or subdomain you plan to use.

map $http_upgrade $connection_upgrade {
default upgrade;
''      close;
}

server {
  listen      80;
  server_name pad.yourdomain.com;
  rewrite     ^(.*)   https://$server_name$1 permanent;
  }

server {
    listen       443 ssl;
    server_name  pad.yourdomain.com;

    access_log  /var/log/nginx/eplite.access.log;
    error_log   /var/log/nginx/eplite.error.log;

    ssl_certificate      /path/to/your/certificate.crt;
    ssl_certificate_key  /path/to/your/private.key;

    location / {
        proxy_pass             http://localhost:9001/;
        proxy_set_header       Host $host;
        proxy_pass_header Server;
        # be careful, this line doesn't override any proxy_buffering on set in a conf.d/file.conf
        proxy_buffering off;
        proxy_set_header X-Real-IP $remote_addr;  # https://wiki.nginx.org/HttpProxyModule
        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_set_header Host $host;  # pass the host header
        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;
    }

Now all you have to do is activate the site. Again, remember to replace “pad.yourdomain’ with the domain or subdomain you plan to use.

# ln -s /etc/nginx/sites-available/pad.yourdomain.conf /etc/nginx/sites-enabled/pad.yourdomain.conf

And restart Nginx:

# systemctl restart nginx

If all went well, your Etherpad installation is available at https://[pad.yourdomain.com]/, and you can access the administration interface from https://[pad.yourdomain.com]/admin/, replacing [pad.yourdomain.com] with the domain or subdomain you used above. Congratulations!

References :