Show Advanced KnowledgeHide Advanced KnowledgeEtherpad-Lite
Add a Pad-Subdomain
nano /etc/apache2/sites-available/pad.bbs-ilias.conf
- Copy the code below:
<VirtualHost pad.kivinet.de:80> ServerName pad.kivinet.de ProxyPreserveHost On ProxyPass / http://127.0.0.1:9001/ ProxyPassReverse / http://127.0.0.1:9001/ # Add this for WebSocket support RewriteEngine On RewriteCond %{HTTP:Upgrade} websocket [NC] RewriteCond %{HTTP:Connection} upgrade [NC] RewriteRule ^/?(.*) ws://127.0.0.1:9001/$1 [P,L] # Logging (Optional, helps with debugging) ErrorLog ${APACHE_LOG_DIR}/pad.kivinet.de_error.log CustomLog ${APACHE_LOG_DIR}/pad.kivinet.de_access.log combined </VirtualHost> |
- Replace kivinet with your domain
a2ensite pad.bbs-ilias.conf systemctl restart apache2 certbot |
Add a user for the service and download and start the program
useradd --home /opt/etherpadlite --shell /bin/nologin etherpad install -d -m 755 -o etherpad -g etherpad /opt/etherpadlite cd /opt/etherpadlite sudo -u etherpad git clone https://github.com/ether/etherpad-lite.git . sudo -u etherpad git checkout master sudo -u etherpad git checkout 1.9.7 ./bin/installDeps.sh etherpad bin/run.sh |
Create Database
mysql
- Create Database "etherpad": mysql>
CREATE DATABASE etherpad CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
- Create Databaseuser "epuser1": mysql>ย
CREATE USER 'epuser1'@'localhost' IDENTIFIED BY 'USER_PASSWORD';
- Give user "epuser1" rights to database "etherpad": mysql>ย
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, INDEX, DROP, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON etherpad.* TO 'epuser1'@'localhost';
Configure the Server
cp settings.json.template settings.json
nano settings.json
- Have a look at this section:
1 2 3 4 5 6 7 8 9 10 11 | /* "dbType" : "mysql", "dbSettings" : { "user": "etherpaduser", "host": "localhost", "port": 3306, "password": "PASSWORD", "database": "etherpad_lite_db", "charset": "utf8mb4" }, */ |
- Remove the comments
/*
and */
- Fill in the database credentials from above
- Comment out the dirty db credentials above:
1 2 3 4 5 6 7 | /* "dbType": "dirty", "dbSettings": { "filename": "var/dirty.db" }, */ |
#If available: "authenticationMethod": "${AUTHENTICATION_METHOD:apikey}", "trustProxy": true, "requireSession": true, "minify": false, abiword": "/usr/bin/abiword", "soffice": "/usr/bin/soffice", |
- "trustProxy": true,
"requireSession": true,
"minify": false,
abiword": "/usr/bin/abiword",
- "soffice": "/usr/bin/soffice",
- Remove
/*
and */
and change passwords for admin and user (changeme1):
- Remove
/*
and */
and change passwords for admin and user (changeme1):
"users": { "admin": { // 1) "password" can be replaced with "hash" if you install ep_hash_auth // 2) please note that if password is null, the user will not be created "password": "changeme1", "is_admin": true }, "user": { // 1) "password" can be replaced with "hash" if you install ep_hash_auth // 2) please note that if password is null, the user will not be created "password": "changeme1", "is_admin": false } }, |
"loglevel": "WARN", #Exit nano export NODE_ENV=production #Run again: sudo -u etherpad bin/run.sh #Try to access the pad in the browser: pad.kivinet.de #Stop process after testing with strg+c |
Deploy a Startscript for Etherpad-Lite
nano /etc/init.d/eptherpadlite
!/bin/bash ### BEGIN INIT INFO # Provides: etherpadlite # Required-Start: $local_fs $remote_fs $network $syslog # Required-Stop: $local_fs $remote_fs $network $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts etherpad lite1 # Description: starts etherpad lite1 using start-stop-daemon ### END INIT INFO PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/local/bin" LOGFILE="/var/log/etherpadlite.log" EPLITE_DIR="/opt/etherpadlite" EPLITE_BIN="bin/safeRun.sh" USER="etherpad" GROUP="etherpad" DESC="Etherpad Lite" NAME="etherpadlite" set -e . /lib/lsb/init-functions start() { echo "Starting $DESC... " echo "Preparing Logfile..." if [ -f "$LOGFILE" ]; then echo "Logfile $LOGFILE exists" else touch $LOGFILE fi echo "Check Rightsettings" chown $USER:$GROUP $LOGFILE chown -R $USER:$GROUP $EPLITE_DIR chmod 770 $LOGFILE chmod 770 -R $EPLITE_DIR start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true echo "done" } #We need this function to ensure the whole process tree will be killed killtree() { local _pid=$1 local _sig=${2-TERM} for _child in $(ps -o pid --no-headers --ppid ${_pid}); do killtree ${_child} ${_sig} done kill -${_sig} ${_pid} } stop() { echo "Stopping $DESC... " if test -f /var/run/$NAME.pid; then while test -d /proc/$(cat /var/run/$NAME.pid); do killtree $(cat /var/run/$NAME.pid) 15 sleep 0.5 done rm /var/run/$NAME.pid fi echo "done" } status() { status_of_proc -p /var/run/$NAME.pid "" "etherpad-lite" && exit 0 || exit $? } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; *) echo "Usage: $NAME {start|stop|restart|status}" >&2 exit 1 ;; esac exit |
Harden the service
- We add another script that checks if the service realy runs:
mkdir /opt/scripts
nano /opt/scripts/checkpad
- We add the following code and change line 3:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #!/bin/bash url="https://pad.yourdomain.de" code="OK" status=$(curl -s --head $url | head -n 1) echo $status string="$status" if [[ $string == *${code}* ]]; then echo "Etherpad up" else echo "Etherpad seems to be down..." status60=$(curl -s --head $url | head -n 1) echo $status string60="$status" if [ -f /var/run/etherpadlite.pid ] then echo "Etherpad process active, try to stop..." systemctl stop etherpadlite sleep 10 rm /var/run/etherpadlite.pid fi systemctl start etherpadlite fi |
chmod +x /opt/scripts/checkpad
Crontab settings
nano /etc/crontab
- Paste this:
1 2 3 4 5 | #Check Etherpad every 2 minutes if it runs. If not, it will be restarted */2 * * * * root /opt/scripts/checkpad > /dev/null 2>&1 #Stop Etherpad-Lite once a day (the line above will restart it automatically) 1 6 * * * root /etc/init.d/etherpadlite stop >/dev/null 2>&1 |
Install Etherpad-Plugins
- To call the admin page type in your browser:
pad.yourdmain.de:/admin
- Login with the admin-credentials you set in the file settings.json
- Choose "Plugin-Manager"
- I recomend to install only two or three plugins because plugins are always dangerous and their use can lead to crashes. I recommend only:
Configuring ILIAS
mkdir -pย /var/www/html/ilias/Customizing/global/plugins/Services/Repository/RepositoryObject
cd /var/www/html/ilias/Customizing/global/plugins/Services/Repository/RepositoryObject
git clone https://github.com/jrocho/ILIAS-Etherpad-Lite-Plugin.git EtherpadLite
- Adjust right settings:
chmod -R 775 EtherpadLite
chown -R www-data:www-data EtherpadLite
- Login to ILIAS and call Administration-Plugins
- Update the Plugin (Aktualisieren)
- Configure the plugin (regard only the right https-column):
Setting | http | http port 80 | https |
Host | bbs-ilias | pad.bbs-ilias.de | pad.bbs-ilias.de |
Port | 9001 | 80 | 443 |
Apikey | Content of APIKEY.txt | Content of APIKEY.txt | Content of APIKEY.txt |
Domain | .bbs-ilias.de | .bbs-ilias.de | .bbs-ilias.de |
https | unchecked | checked | checked |
EP-Version | >=1.4 | >=1.4 | >=1.4 |
Usergroup | leave empty | leave empty | leave empty |
- In ILIAS try in the repository the new object EterpadLite :)
Troubleshooting
You can find errors in /var/log/etherpadlite.log
#1 Problem: npm ERR! Your cache folder contains root-owned files
1 2 3 4 5 6 7 8 9 10 | npm ERR! npm ERR! Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which has since been addressed. npm ERR! npm ERR! To permanently fix this problem, please run: npm ERR! sudo chown -R 33:33 "/var/www/.npm" npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /var/www/.npm npm ERR! errno -13 |
Solution
- Run the service with a user which has its home-directroy in /opt/etherpadlite (as described above)
#2 Plugins install problems or start problems generally
npm config set registry http://registry.npmjs.org/ --global
npm cache clear --force
npm install --verbose