Friday, June 14, 2024
HomeHow toHow to Install Etherpad Collaboration Editor on Ubuntu 24.04 Server

How to Install Etherpad Collaboration Editor on Ubuntu 24.04 Server

Etherpad is an open-source collaborative and real-time text editor for your team, accessible from anywhere at any time because Etherpad is a web-based text editor. Etherpad supports versioning and built-in formatting for teams and offers a highly customizable editor with the support of various plugins. It also supports modern document formats such as doc, pdf, odt, markdown, etc.

In this guide, we’ll walk you through the installation process of the Etherpad collaboration editor onto the Ubuntu 24.04 server. You will set up Etherpad with the MariaDB database server, Nginx as a reverse proxy, then secure Etherpad with HTTPS through Certbot and Letsencrypt.

Prerequisites

To begin with this guide, make sure you have the following:

An Ubuntu 24.04 server.
A non-root user with administrator privileges.
A domain name pointed to a server IP address.

Installing Dependencies

Etherpad is a collaborative real-time editor written in Node.js. To install it, you must install package dependencies such as Node.js, NPM, and Git. Etherpad also required Python3 and MySQL/MariaDB for the database.

First, update your Ubuntu repository with the following:

sudo apt update

Now, install dependencies for Etherpad using the command below. With this command, you will install the MariaDB server, Nginx, Node.js, Python3, Git, and some essential tools.

sudo apt install mariadb-server nginx nodejs npm gzip git curl python3 libssl-dev

Type Y to confirm the installation.

After the installation, check the MariaDB and Nginx services to ensure both services are running.

Check the MariaDB service with the following:

sudo systemctl is-enabled mariadb
sudo systemctl status mariadb

As you can see below, the MariaDB service is running and will start at boot automatically.

Now check the Nginx service using the command below. You should get a similar output when the Nginx service is running and enabled.

sudo systemctl is-enabled nginx
sudo systemctl status nginx

Lastly, check the Node.js version with the command.

node -v

Make sure you have Node.js v18.x or more. The Etherpad supports Node.js v18 and above.

Setting up the MariaDB server

After you’ve installed dependencies, you will configure the MariaDB server and create a new database and user for Etherpad. You will secure MariaDB using the ‘mariadb-secure-installation’ utility, then set up the database and user through the MariaDB client.

To secure your MariaDB server, execute the following:

sudo mariadb-secure-installation

You will be prompted with MariaDB server configurations:

  1. The default MariaDB installation comes without a password, press ENTER when prompted for the password.
  2. Now input Y to set up the MariaDB root password. Then, type the new password for MariaDB and repeat the password.
  3. Input Y to remove the anonymous user from your MariaDB installation.
  4. Input Y again when prompted to disable the remote login for the MariaDB root user.
  5. Input Y to remove the default database test from your MariaDB.
  6. Lastly, input Y to reload table privileges and apply new changes.

After you have secured and configured the MariaDB server, you will create a new database and user for Etherpad.

Log in to the MariaDB server with the following command. Input MariaDB root password when prompted.

sudo mariadb -u root -p

Next, run the following MariaDB queries to create a new database ‘etherpad_db‘, a user ‘etherpad‘, with the password ‘StrongPasswordEtherpadDB‘. You can adjust the following database details with your information.

CREATE DATABASE etherpad_db;
CREATE USER etherpad@localhost IDENTIFIED BY 'StrongPasswordEtherpadDB';
GRANT CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE on etherpad_db.* to etherpad@localhost;
FLUSH PRIVILEGES;

Now run the following query to ensure that user ‘etherpad‘ can access the database ‘etherpad_db‘.

SHOW GRANTS FOR etherpad@localhost;

You can see below user ‘etherpad‘ with multiple privileges to the database ‘etherpad_db‘.

Lastly, type quit to exit from the MariaDB server.

Installing Etherpad Lite

After creating the database and user, you will download the Etherpad source code, install Etherpad dependencies with the installer script, and then configure Etherpad installation with the MariaDB server.

By default, Etherpad uses the pnpm package manager to manage the installation, so you must install the ‘pnpm’ globally to your system first.

First, install the pnpm package globally (-g) using the following npm command. By default, the Etherpad project uses pnpm as a Node.js package manager instead of standard npm.

npm install pnpm -g

Now run the command below to create a new system user ‘etherpad‘. This user will be used to run the Etherpad application.

sudo adduser --system --no-create-home --home=/opt/etherpad-lite --group etherpad

Next, go to the /opt and download the Etherpad source code to the ‘etherpad-lite‘ directory with git. Then, change the ownership of the ‘/opt/etherpad-lite‘ directory to the user ‘etherpad‘.

cd /opt && git clone --branch master https://github.com/ether/etherpad-lite.git 
sudo chown -R etherpad:etherpad /opt/etherpad-lite

Afterward, go to the ‘opt/etherpad-lite’ directory and install Node.js dependencies for Etherpad with the following.

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

Below is the download process for Etherpad dependencies using pnpm package manager.

After dependencies are installed, the Etherpad should be running automatically. You can see below that Etherpad 2.0.3 is running.

Press Ctrl+c to terminate the current Etherpad process. You will be configuring Etherpad with the MariaDB database.

Now open the file ‘settings.json‘ with the following nano editor.

nano settings.json

Change the title for your Etherpad installation.

 "title": "Etherpad Ubuntu 24",

Change the default IP address to 12.0.0.1 or localhost. This will start the Etherpad process in localhost only.

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

Comment the default ‘dirty‘ database configuration like the following:

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

Insert the configuration below to set up a database with the MariaDB server. Make sure to change the details of the database information with yours.

 "dbType" : "mysql",
"dbSettings" : {
"user": "etherpad",
"host": "127.0.0.1",
"port": 3306,
"password": "StrongPasswordEtherpadDB",
"database": "etherpad_db",
"charset": "utf8mb4"
},

When finished, save the file and exit the editor.

Running Etherpad as a systemd service

Now that you have installed and configured Etherpad, you will create a new systemd service file for Etherpad. With this, you will run Etherpad in the background, and you can manage Etherpad through the ‘systemctl’ command.

Create a new systemd service file for Etherpad ‘/etc/systemd/system/etherpad.service‘ with the nano editor.

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

Add the following configuration to the file. With this, you will run Etherpad in the background as a systemd service through the ‘pnpm’ command.

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

[Service]
Type=simple
User=etherpad
Group=etherpad
WorkingDirectory=/opt/etherpad-lite
ExecStart=/usr/local/bin/pnpm run prod
# use mysql plus a complete settings.json to avoid Service hold-off time over, scheduling restart.
Restart=always

[Install]
WantedBy=multi-user.target

Save the file and exit.

Now run the command below to reload the systemd manager and apply the Etherpad service file.

sudo systemctl daemon-reload

After the systemd reloads, start and enable the ‘etherpad’ service with the following systemctl command.

sudo systemctl start etherpad
sudo systemctl enable etherpad

Next, run the command below to check the Etherpad service status and make sure that the service is running.

sudo systemctl status etherpad

You can see below the Etherpad service is running as a service.

Lastly, check the default Etherpad port 9001 with the ‘ss’ command below. You should see port 9001 is used by the Etherpad process.

ss -tulpn | grep 9001

Setting up Nginx as a reverse proxy

You will run Etherpad with Nginx as a reverse proxy in this guide. So now you will create the Nginx server block configuration for Etherpa, and ensure you have prepared your domain name for Etherpad.

Use the following nano editor command to create a new Nginx server block ‘/etc/nginx/sites-available/etherpad.conf’.

sudo nano /etc/nginx/sites-available/etherpad.conf

Add the following configuration and change the server_name option with your domain name. With this configuration, you will use Nginx as a reverse proxy for Etherpad, which runs on port 9001.

```
server {
listen 80;
server_name etherpad.hwdomain.io;

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

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 "upgrade";
}

}

Save and close the file when finished.

Now run the command below to activate the server block ‘etherpad.conf‘ file and verify your Nginx syntax.

sudo ln -s /etc/nginx/sites-available/etherpad.conf /etc/nginx/sites-enabled/
sudo nginx -t

You should get an output ‘nginx is ok…test is successful‘ with proper Nginx syntax.

Lastly, run the command below to restart the Nginx service and apply your new server block. After executing the command, your Etherpad is accessible through the Nginx web server.

sudo systemctl restart nginx

Securing Etherpad with HTTPS

After configuring the Nginx reverse proxy, you will secure Etherpad with HTTPS. If you’re using the public domain, you can use the following steps to set up HTTPS with Certbot and Letsencrypt. Local domain users can use self-signed certificates.

Install Certbot and the Certbot Nginx plugin using the following command. When prompted, Type Y to confirm the installation.

sudo apt install certbot python3-certbot-nginx

Now run the following certbot command to generate SSL/TLS certificates from Letsencrypt. Make sure to change the domain name and email address with your details.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d etherpad.hwdomain.io

After completing the process, your certificates will be available in the ‘/etc/letsencrypt/live/domain.com‘ directory. Also, your Etherpad installation should automatically run with HTTPS through the Certbot Nginx plugin.

Accessing Etherpad

Visit your Etherpad domain name https://etherpad.hwdomain.io to access your Etherpad installation. If successful, you will get the following page:

Type the new name for your first pad and click OK to confirm.

Now you will see the document editor for Etherpad. You can now edit the document at the same time as your friends or colleagues.

Conclusion

Congratulations! You have installed the Etherpad collaboration editor on the Ubuntu 24.04 server. You’ve Etherpad running with the MariaDB database server and Nginx web server. Also, you have secured Etherpad with HTTPS through Certbot and Letsencrypt.


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Most Popular