How to Install Collaborative Real-time Editor Etherpad on Ubuntu 18.04

Etherpad is a real-time collaborative editor based on Node.js. It’s an open source, web-based collaborative editor for multi-user access with the ability to import/export to various office file formats and highly customizable online editor.

In this tutorial, I will guide you step-by-step to install and configure the Etherpad-lite on Ubuntu 18.04 Server. We will install the Etherpad-lite with the MySQL as a database, the Nginx web server as a reverse proxy, and enable the HTTPS secure connection on it.

Prerequisites

  • Ubuntu 18.04 server
  • Root privileges

What we will do?

  1. Install Packages Dependencies
  2. Install Nodejs
  3. Install and Configure MySQL
  4. Download Etherpad
  5. Configure Etherpad
  6. Setup Etherpad as a Service
  7. Setup Nginx as a Reverse Proxy for Etherpad
  8. Setup UFW Firewall
  9. Testing

Step 1 – Install Packages Dependencies

The first step we will do in this guide is to install all package dependencies for Nodejs installation.

Run the apt command below.

sudo apt install gzip git curl python libssl-dev pkg-config gcc g++ make build-essential -y

Wait for all installation.

Step 2 – Install Nodejs

Etherpad requires Node.js >= 6.9, and in this step we will install Nodejs 9.11 that can be installed from the nodesource repository.

Add the nodesource Nodejs repository and install the Node.js package using commands below.

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt install -y nodejs

After this, check the nodejs and npm commands.

nodejs --version
npm --version

The Node.js v9.11 has been installed on Ubuntu 18.04 server.

Install node.js

Step 3 – Install and Configure MySQL

In this tutorial, we will be using MySQL as the database for Etherpad.

Install MySQL database server using the apt command below.

sudo apt install mysql-server mysql-client

After the installation is complete, start the mysql service and enable it to launch everytime at system boot.

sudo systemctl start mysql
sudo systemctl enable mysql

The MySQL server has been installed.

Next, we will configure the mysql root password and create a new database and user for our etherpad installation.

To configure the MySQL root password, run the command below.

mysql_secure_installation

Type your strong mysql root password.

Now login to the mysql shell using root user.

mysql -u root -p

Create a new database named ‘etherpad_db’ and user ‘hakase’, and run mysql queries below.

create database etherpad_db;
grant all privileges on etherpad_db.* to [email protected] identified by '[email protected]#';
flush privileges;

MySQL database for etherpad installation has been created.

Install MySQL

Step 4 – Download Etherpad

In this step, we will create a new user and download the etherpad source code.

Create a new user named ‘etherpad’ and login to the user.

useradd -m -s /bin/bash etherpad
su - etherpad

Now clone the etherpad repository.

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

Go to the ‘etherpad-lite/’ directory and run the bash script to start etherpad.

cd etherpad-lite/
bin/run.sh

You will get the result as below.

Download Etherpad

Open your web browser and type the server IP address with port ‘9001’.

http://192.168.33.10:9001/

And you will see the etherpad home page.

Access Etherpad

Back to your terminal and press ‘Ctrl+c’ to exit from the application.

Step 5 – Configure Etherpad

In this step, we will do the basic configuration of etherpad collaborative editor.

Login to the etherpad user and go to the ‘etherpad-lite’ directory.

su - etherpad
cd etherpad-lite/

Edit the configuration ‘settings.json’ using vim editor.

vim settings.json

Change the ip address to ‘127.0.0.1’ or localhost, because we will run the etherpad on Nginx reverse proxy.

  "ip": "127.0.0.1",
  "port" : 9001,

Now disable the default dirty database by adding the comment ‘/* …. */’, and paste the MySQL database configuration.

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

MySQL database configuration.

  "dbType" : "mysql",
  "dbSettings" : {
                   "user"    : "hakase",
                   "host"    : "localhost",
                   "port"    : 3306,
                   "password": "[email protected]#",
                   "database": "etherpad_db",
                   "charset" : "utf8mb4"
                 },

Etherpad configuration

Next, we will enable the admin user by removing the comment from those lines and change the password value with a new password.

  "users": {
    "admin": {
      // "password" can be replaced with "hash" if you install ep_hash_auth
      "password": "[email protected]#",
      "is_admin": true
    },
    "user": {
      // "password" can be replaced with "hash" if you install ep_hash_auth
      "password": "[email protected]#",
      "is_admin": false
    }
  },

Configure password

Save and exit.

The basic etherpad configuration has been completed.

Step 6 – Setup Etherpad as a service

Now we will run etherpad as a systemd service on our ubuntu system.

Go to the ‘/etc/systemd/system’ directory and create a new service file named ‘etherpad.service’.

cd /etc/systemd/system/
vim etherpad.service

Paste configurations below.

[Unit]
Description=Etherpad-lite, the collaborative editor.
After=syslog.target network.target[Service]
Type=simple
User=etherpad
Group=etherpad
WorkingDirectory=/home/etherpad/etherpad-lite
Environment=NODE_ENV=production
ExecStart=/usr/bin/nodejs /home/etherpad/etherpad-lite/node_modules/ep_etherpad-lite/node/server.js
Restart=always # use mysql plus a complete settings.json to avoid Service hold-off time over, scheduling restart.

[Install]
WantedBy=multi-user.target

Save and exit.

Reload the systemd service lists.

sudo systemctl daemon-reload

Start the etherpad service and enable it to launch every time at system boot.

sudo systemctl start etherpad
sudo systemctl enable etherpad

And the ether is up and running as a service on localhost ip with the default port 9001.

Run Etherpad as a service

Check the service using commands below.

sudo systemctl status etherpad
netstat -plntu

Step 7 – Install and Configure Nginx as a Reverse proxy

In this step, we will install and configure Nginx web server as a reverse proxy for etherpad service.

Install the nginx web server using apt command below.

sudo apt install nginx -y

After the installation is complete, go to the ‘/etc/nginx/sites-available’ directory and create a new virtual host ‘etherpad’.

cd /etc/nginx/sites-available/
vim etherpad

Paste configurations below.

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

# we're in the http context here
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

server {
        listen       443;
        server_name  pad.hakase.io;

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

        ssl                  on;
        ssl_certificate      /etc/nginx/ssl/fullchain.pem;
        ssl_certificate_key  /etc/nginx/ssl/privkey.pem;

        ssl_session_timeout  5m;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";

        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;  # http://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 http://nginx.org/en/docs/http/websocket.html
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;

        }
}

Save and exit.

Note:

  • Make sure you change the path of the SSL with your own ssl certificates.
  • Change the etherpad domain ‘pad.hakase.io’ with your own domain name.

Now activate the etherpad virtual host and test the configuration.

ln -s /etc/nginx/sites-available/etherpad /etc/nginx/sites-enabled/
nginx -t

Make sure there is no error, then start the nginx service and enable it to launch everytime at system boot.

sudo systemctl restart nginx
sudo systemctl enable nginx

Etherpad behind nginx proxy

The Nginx installation and configuration as etherpad reverse proxy has been completed successfully.

Step 8 – Setup UFW Firewall

For the firewall setup, we just want to open the SSH, HTTP, and HTTPS port services.

Run ufw commands below.

sudo fuw allow ssh
sudo ufw allow http
sudo ufw allow https

Then enable the ufw firewall.

sudo ufw enable

And the ufw firewall configuration has been completed.

Step 9 – Testing

Open your web browser and type the etherpad domain name, mine is: http://pad.hakase.io/

Now you will be redirected to the HTTS secure connection.

Access Etherpad

Create a new pad by typing the pad name on the box and click the ‘OK’ button.

And you will get the Etherpad editor as below.

Etherpad Editor

Next, open the etherpad admin URL. Mine is https://pad.hakase.io/admin/

You will be asked the admin username and password. Type your own user and password, then click the Signin button.

Etherpad admin area

And you will get the default Etherpad admin page below.

– Etherpad settings.json Configuration

Etherpad settings.json Configuration

– Etherpad Plugin Manager

Plugin manager

The Etherpad installation with MySQL and Nginx reverse proxy on Ubuntu 18.04 has been completed successfully.

Reference

نوشته های مشابه