How to Install Etherpad on AlmaLinux 9

Etherpad is a free and open-source alternative to services like Google Docs and Zoho Writer. Etherpad is a collaborative and real-time text editor for your team, it's accessible from anywhere at any time because Etherpad is a web-based text editor.

Any changes on Etherpad are happening in real-time, and also etherpad supports versioning and built-in formatting for teams. Etherpad is a highly customizable editor with the support of various plugins. And also supports modern document formats such as doc, pdf, odt, markdown, etc.

This tutorial will show you how to install Etherpad on an AlmaLinux 9 server with a MariaDB database server and an Nginx web server. You will also secure Etherpad via SSL certificates to enable secure access.

Prerequisites

To complete this tutorial, ensure you have the following:

  • An AlmaLinux 9 server - This demo uses an AlmaLinux with the hostname almalinux9.
  • A non-root user with sudo privileges.
  • A domain name pointed to the server IP address.
  • Generated SSL Certificates via Letsecnrypt and Certbot.

Installing Dependencies

Before installing Etherpad, you must install some of the dependencies that are needed by Etherpad, including:

  • Development Tools
  • Node.js and NPM (Node Package Manager)
  • MariaDB database server
  • Nginx web server

Complete these steps to install Etherpad dependencies.

Installing Development Tools

First, you must install "Development Tools" on your AlmaLinux server. Enter the following dnf command to install "Development Tools", input y, and press ENTER to proceed.

sudo dnf group install "Development Tools"

Next, run the following command to install some additional dependencies. When prompted, input y to confirm and press ENTER.

sudo dnf install gzip git curl python3-devel openssl-devel pkg-config

install dependencies

Installing Node.js and NPM

Etherpad is a web-based collaboration and real-time editor mainly written with Node.js. To install it, you must install the Node.js JavaScript runtime and NPM (Node Package Manager).

At the time of this writing, Etherpad required at least Node.js v16, which is available by default on the AlmaLinux appstream repository and you can install it via DNF.

Run the following dnf command to install Node.js and NPM. Input y to confirm the installation and press ENTER.

sudo dnf install nodejs npm

Once Node.js is installed, run the following command to add the /usr/local/bin directory to the PATH environment variable. This will ensure some binary files that are installed via NPM can be run on the server.

echo "export PATH=$PATH:/usr/local/bin" >> ~/.bashrc
source ~/.bashrc

Next, run the following command to locate both binary files of Node.js and NPM.

which node
which npm

Then, verify the Node.js and NPM version using the command below.

node --version
npm --version

The displayed output confirms that Node.js v16 and NPM 8. x are installed, and both binary files are located in the /bin directory.

checking node.js and npm

Installing MariaDB Server

By default, the Etherpad installed used SQLite as the database. You can use MariaDB/MySQL as the database for large deployments for your Etherpad installation.

Run the dnf command below to install MariaDB Server. When prompted, input y to confirm and press ENTER.

sudo dnf install mariadb-server

install mariadb

Once MariaDB is installed, run the following command to start and enable the MariaDB service.

sudo systemctl start mariadb
sudo systemctl enable mariadb

Then, verify the MariaDB service status using the command below.

sudo systemctl status mariadb

If the MariaDB server is running, the output should be displayed like this:

start enable mariadb

Installing Nginx Web Server

After installing MariaDB Server, you will be installing the Nginx web server that will be used as a reverse proxy for Etherpad. So, before going any further, ensure that you have a domain name pointed to your server IP address and SSL certificates generated via Letsencrypt and Certbot.

Run the dnf command below to install the Nginx web server. When prompted, input to confirm and press ENTER.

sudo dnf install nginx

install nginx

Now, run the following command to start and enable the Nginx service.

sudo systemctl start nginx
sudo systemctl enable nginx

After that, enter the following command to verify the Nginx service and ensure that the service is running.

sudo systemctl status nginx

If the Nginx service is running, you should get an output like this:

start enable verify nginx

Next, run the following command to open HTTP and HTTPS ports on your server.

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Verify the list of open ports and services using the following command. You should see both HTTP and HTTPS are enabled on firewalld.

sudo firewall-cmd --list-all

configure firewalld

Configuring MariaDB Server

In this section, you will be securing the MariaDB server with the mariadb-secure-installation utility, then creating a new database and user that will be used for Etherpad.

Run the following command to start securing the MariaDB server.

sudo mariadb-secure-installation

After the command is executed, you will be asked about the following configurations:

  • Change the authentication method for the MariaDB root user to unix_socket. Input n for No.
    Setting up the MariaDB root password. Input y to confirm and type the new MariaDB root password and repeat.
    Disable remote login for MariaDB root user. Input y to confirm.
    Remove the Default database test from MariaDB. Input y to confirm.
    Remove anonymous user from the MariaDB. Input y to confirm.
    Lastly, input y again to reload table privileges to apply the changes.

With the MariaDB server secured, you will next be creating a new MariaDB database and user.

Log in to the MariaDB server using the mariadb command below.

sudo mariadb -u root -p

Run the following queries to create a new MariaDB database and user for Etherpad. In this example, you'll create a new database etherpad_lite_db and the user etherpaduser with the password StrongPasswordEtherpadDB.

CREATE DATABASE etherpad_lite_db CHARACTER SET utf8mb4;
CREATE USER etherpaduser@localhost IDENTIFIED BY 'StrongPasswordEtherpadDB';
GRANT CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE on etherpad_lite_db.* to etherpaduser@localhost;
FLUSH PRIVILEGES;

create new database and user

Now, run the following query to verify the privileges for the MariaDB user etherpaduser.

SHOW GRANTS FOR etherpaduser@localhost;
quit

You will notice that the MariaDB user etherpaduser has privileges to access the database etherpad_lite_db.

show mariadb user privileges

Type quit to exit from the MariaDB.

Downloading and Installing Etherpad

In this section, you will start the Etherpad installation by creating the system user, downloading the Etherpad source code, installing dependencies for Etherpad, integrating Etherpad with the MariaDB database, then verifying the installation by running it via the command line.

First, run the following command to create a new system user and group 'etherpad'. This user will be used to run the Etherpad service.

sudo groupadd etherpad
sudo adduser -r -M -d /opt/etherpad-lite -g etherpad etherpad

Download the Etherpad source code via git to the target directory /opt/etherpad-lite.

git clone --branch master https://github.com/ether/etherpad-lite.git /opt/etherpad-lite

Once the Etherpad source code is downloaded, run the following command to change the ownership of directory /opt/etherpad-lite to the user and group 'etherpad'.

sudo chown -R etherpad:etherpad /opt/etherpad-lite

create user and download etherpad source code

Next, move the working directory to /opt/etherpad-lite directory and install Etherpad dependencies using the command below.

cd /opt/etherpad-lite
sudo su -s /bin/bash -c "./bin/installDeps.sh" etherpad

After executing the command, you should get the installation process like this:

install etherpad dependencies

When the installation is finished, open the Etherpad configuration settings.json using the following nano editor command.

nano settings.json

Change the title of your Etherpad installation.

  "title": "Etherpad AlmaLinux 9",

Change the default IP address for Etherpad to run to localhost or 127.0.0.1.

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

Remove the default database configuration below.

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

Change the details database to use MySQL/MariaDB server like this. And be sure to change the database name, user, and password.

  "dbType" : "mysql",
  "dbSettings" : {
    "user":     "etherpaduser",
    "host":     "localhost",
    "port":     3306,
    "password": "StrongPasswordEtherpadDB",
    "database": "etherpad_lite_db",
    "charset":  "utf8mb4"
  },

Save the file and exit the editor when you're finished.

Next, execute the following command to verify and run the Etherpad.

/bin/node --experimental-worker /opt/etherpad-lite/node_modules/ep_etherpad-lite/node/server.js

If the database configuration and Etherpad installation are successful, the following output will be displayed:

running check etherpad

Press Ctrl+c to terminate the process.

Running Etherpad as Systemd Service

With the Etherpad installed, you now will be setting up Etherpad as a systemd service. This allows you to run Etherpad in the background and easily manage Etherpad via the systemctl command line.

To start, create a new systemd service file /lib/systemd/system/etherpad.service using the following nano editor command.

sudo nano /lib/systemd/system/etherpad.service

Insert the following configuration into the file.

[Unit]
Description=Etherpad-lite, the collaborative editor.
After=syslog.target network.target mariadb.service nginx.service

[Service]
Type=simple
User=etherpad
Group=etherpad
WorkingDirectory=/opt/etherpad-lite
Environment=NODE_ENV=production
ExecStart=/bin/node --experimental-worker /opt/etherpad-lite/node_modules/ep_etherpad-lite/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

Save and close the file when you're finished.

Now, run the following command to reload the systemd manager and apply the Etherpad service file to your system.

sudo systemctl daemon-reload

Then, start and enable the Etherpad service using the command below.

sudo systemctl start etherpad
sudo systemctl enable etherpad

Verify the Etherpad service using the following command. If the Etherpad service is running, you should get an output such as 'active (running)'.

sudo systemctl status etherpad

verify etherpad service

You can also verify the list of open ports on your system using the following command. And you should see Etherpad uses that port 9001.

ss -tulpn | grep 9001

check etherpad port

Configuring Nginx as a Reverse Proxy

At this point, the Etherpad is up and running on port 9001. To make it accessible for end-users, you can use Nginx which will be used as a reverse proxy. Before you start, ensure that you have the domain name that will be used for Etherpad, and be sure you have generated SSL certificates via Letsencrypt and Certbot.

Create a new Nginx server block configuration /etc/nginx/conf.d/etherpad.conf using the nano editor command below.

sudo nano /etc/nginx/conf.d/etherpad.conf

Insert the following configuration and be sure to change the details of the domain name and the path of SSL certificates.

# enforce HTTPS
server {
    listen       80;
    server_name  etherpad.hwdomain.io;
    return 301   https://$host$request_uri;
}

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

server {
    listen       443 ssl http2;
    server_name  etherpad.hwdomain.io;

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

    ssl_certificate      /etc/letsencrypt/live/etherpad.hwdomain.io/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/etherpad.hwdomain.io/privkey.pem;

    ssl_session_timeout  5m;

    ssl_protocols 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://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;
    }
}

Save the file and close the editor when finished.

Now, run the following command to ensure that you have the correct and proper configuration. If successful, you should get a message such as "Syntax is ok - test is successful".

sudo nginx -t

Next, enter the following command to restart the Nginx service and apply the changes.

sudo systemctl restart nginx

configure nginx as reverse proxy

After that, launch your web browser and visit the Etherpad installation domain name (i.e: https://etherpad.hwdomain.io/). You should see the default home page of your Etherpad collaborative editor.

Now create a new pad by typing the pad name and click OK.

create new pad

Below you can see now start using Etherpad as the collaborative editor.

etehrpad collaboratuive editor

Conclusion

Congratulations, you have completed the installation of Etherpad with MariaDB database and Nginx web server on an AlmaLinux 9 server. You have also secured Etherpad with SSL certificates on top of that. You can now start using Etherpad as a main collaborative editor with your friends/groups/team.

Share this page:

0 Comment(s)