How To Deploy Linux Ubuntu 20.04 LTS In The Cloud On AWS Lightsail And Install The Etherpad Lite Document Collaboration Web App.

REQUIREMENTS
In order to complete this tutorial successfully the following items that may be required. Please ensure to have these items available before taking implementation action on this tutorial to ensure success:
1) An AWS free tier account.
2) An IAM user account with permissions to provision resources in AWS Lightsail.
3) A Linux Ubuntu 20.04 instance.
4) The WGET package.
5) The etherpad lite document collaboration web app.
OVERVIEW
1) Sign up or log into your AWS free tier or paid account and open the AWS LIGHTSAIL management console.
2) Create a new LINUX UBUNTU 20.04 LTS instance and configure a static public IP address.
3) Connect to the LINUX UBUNTU 20.04 LTS using the AWS Lightsail browser based SSH client.
4) Install ubuntu system, package updates and install GIT.
5) Install the ETHERPAD LITE document collaboration web app.
Step 1: Sign Up Or Log Into Your AWS Free Tier Or Paid Account And Open The AWS LIGHTSAIL Management Console
1) Click HERE to go to the AWS sign up page, to sign up for a free tier account. The free tier account allows you to explore more than 100 products and start building on AWS without having to make any upfront payments or commitments.
However there are 3 different types of free access that are available on AWS services and these are:
1) 12 months free.
2) Free trials.
3) Always free.
Once you have complete the free tier account sign up process we recommend that you create an IAM user account that will be used to create and manage AWS services.Click HERE to learn how to create an IAM user


Step 2: Create A New LINUX UBUNTU 20.04 LTS Instance And Configure A Static Public IP Address

4) AWS LIGHTSAIL will automatically select the best location for the instance however if you would like to change the location of the instance click on the “CHANGE AWS REGION AND AVAILABILITY ZONE” link..
On the SELECT A PLATFORM section, select the LINUX / UNIX option and on the SELECT A BLUEPRINT section, click on the OS ONLY tab and click on UBUNTU 20.04 LTS.

5) You can all a shell script that will run the the instance when it starts up for the first time. To do so, click on the ADD LAUNCH SCRIPT link.
If you would like to change the SSH KEY PAIR that is used to securely connect to the instance, click on the CHANGE SSH KEY PAIR button..
Select the amount of money that you would like to pay, each month for your instance on the CHOOSE YOUR INSTANCE PLAN section. If you select any of the first three plans, you als get the first 3 months FREE!



8) Again AWS LIGHTSAIL will choose the best region where the static IP address will be allocated from but if you would like to change this, click on the “CHANGE AWS REGION AND AVAILABILITY ZONE” link..
Select the linux ubuntu instance on the ATTACH TO AN INSTANCE drop down menu, add a name to identify the static IP address and click on CREATE.

Step 3: Connect To The LINUX UBUNTU 20.04 LTS Instance Using The AWS Lightsail Browser Based SSH Client.


Step 4: Install Ubuntu System & Package Updates And Install GIT


13) Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
In this tutorial the GIT software package will be used to download the ETHERPAD LITE installation files. Run the following command to install GIT:
apt-get install git.

Step 5: Install The ETHERPAD LITE Document Collaboration Web App
14) Next, Run the following command to install the following packages that are needed to install ETHERPAD LIT on Linux Ubuntu 20.04 LTS:
sudo su
apt-get install gnupg2 git unzip libssl-dev pkg-config gcc g++ make build-essential -y

15) The ETHERPAD LITE web application uses a MAIADB database in its backend. So the next thing to do is to install the MARIADB database engine by running the following commands
sudo su
apt-get install mariadb-server -y

16) Next, log into the MARIADB shell an running the following commands to create a MYSQL database for the ETHERPAD LITE web app:
a) mysql
b) MariaDB [(none)]> create database ETHERPADWEBAPP;
c) MariaDB [(none)]> grant all privileges on ETHERPADWEBAPP.* to ETHERPADUSER@localhost identified by ‘ETHERPADPASSWORD’;
d) MariaDB [(none)]> flush privileges;
e) MariaDB [(none)]> exit;


18) Now, run the following command to install NODEJS:
apt-get install nodejs -y
Once the installation is complete, run the following command to confirm the version of NODEJS that has been installed:
node -v
You should get the following output:
v14.18.1

19) Next, run the following command to add a ETHERPAD user in linux ubuntu:
adduser –home /opt/etherpad –shell /bin/bash etherpad-user
You will be prompted to set a password for the ETHERPAD user as shown in the image on the right and on the “IS THE INFORMATION CORRECT” prompt, press Y and press ENTER.

20) Give the newly created ETHERPAD user the correct file permissions for accessing the ETHERPAD application folder by running the following command:
install -d -m 755 -o etherpad-user -g etherpad-user /opt/etherpad

21) Change to ETHERPAD user and download the latest version of ETHERPAD from the Git repository by running the following commands:
su – etherpad
cd /opt/etherpad
git clone https://github.com/ether/etherpad-lite.git

22) Next, go into the etherpad-lite folder and run the following command to install all dependencies & start the ETHERPAD server:
cd etherpad-lite.
bin/run.sh

23) If the dependancy installation process and server start process completes successfully, you should see output as shown in the image on the right.

24) Next, press CNTRL + C on your keyboard to stop the ETHERPAD server and run the following command to edit the settings.json file :
nano settings.json
Remove the following lines for the .json file:
“dbType” : “dirty”,
“dbSettings” : {
“filename” : “var/dirty.db”
},

25) Press CNTRL + W on your keyboard to open the nano search box, type DBTYPE and press ENTER.
Nano will automatically scroll to a section where you can configure the MYSQL database details. Add your mysql database name, username and password and press CNTRL + O to save changes

26) Press CNTRL + W on your keyboard once more to open the nano search box, type TRUSTPROXY and press ENTER.
Set the TRUSTPROXY parameter to TRUE and press CNTRL + O to save changes

27) Press CNTRL + W on your keyboard once more to open the nano search box, type USERS and press ENTER. Enter a password that you will use to log into the ETHERPAD admin account and press CNTRL + O to save changes.

28) Next, run the following command to install ETHERPAD dependancies:
./bin/installDeps.sh
Then exit out of the ETHERPAD user account by runnig the following command:
exit

29) The next step is to create a systemd configuration file that will be used to manage the ETHERPAD service. Run the command indicated below to create the file:
nano /etc/systemd/system/etherpad.service

30) Next, copy and paste the following configuration into the ETHERPAD.SERVICE file and press CNTRL + O to save changes:
[Unit]
Description=Etherpad-lite, the collaborative editor.
After=syslog.target network.target
[Service]
Type=simple
User=etherpad
Group=etherpad
WorkingDirectory=/opt/etherpad/etherpad-lite
Environment=NODE_ENV=production
ExecStart=/usr/bin/node /opt/etherpad/etherpad-lite/src/node/server.js
Restart=always
[Install]
WantedBy=multi-user.target
