MoodleNet Installation

  Lioh Möller   Lesezeit: 8 Minuten

Mit MoodleNet lässt sich eine einfach zugängliche Publikationsplattform für Lerninhalte erstellen.

moodlenet installation

Bei MoodleNet handelt es sich um eine einfache Publikationsplattform für Lerninhalte. Die Software wurde primär für den Einsatz auf der Hauptinstanz moodle.net konzipiert, lässt sich allerdings auch selbst betreiben.

Voraussetzung für eine Installation ist eine aktuelle Ubuntu LTS Version mit vorkonfiguriertem Docker Repository.

Eine offizielle Installationsanleitung findet man im Git Repository des Projektes.

Für die zum Einsatz kommende ArangoDB muss zunächst Docker installiert werden:

sudo apt-get install docker-ce docker-ce-cli containerd.io

Die Datenbankinstanz kann daraufhin wie folgt gestartet werden:

sudo docker run --restart=always -e ARANGO_NO_AUTH=1 -e nolink=1 --name mnarango -p 127.0.0.1:8529:8529 -d arangodb

Alternativ lässt sich ArangoDB mittels einer docker-compose.yml einrichten:

mkdir -p /opt/docker/arangodb/data
cd /opt/docker/arangodb/

vi docker-compose.yaml

version: '3.3'

services:
  mnarango:
    image: arangodb
    restart: always
    environment:
      ARANGO_NO_AUTH: '1'
      nolink: '1'
    ports:
      - 127.0.0.1:8529:8529
    volumes:
      - ./data/db:/var/lib/arangodb3
      - ./data/db-apps:/var/lib/arangodb3-apps

docker-compose up -d

Die Applikation selbst basiert auf node.js, welches aktuell in Version 14 vorausgesetzt wird.

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -

Daraufhin lässt sich nodejs wie folgt installieren:

sudo apt install nodejs

Zur Vorbereitung der Installation von MoodleNet muss zunächst ein separates Benutzerkonto erstellt werden, unter dem der Prozess ausgeführt wird:

groupadd -g 218 moodlenet
useradd -u 218 -g 218 -c "MoodleNet User" -d /home/moodlenet -s /bin/false moodlenet
mkdir /home/moodlenet
chown moodlenet:moodlenet /home/moodlenet

Nachdem der Benutzer angelegt wurde, sollte im Kontext des moodlenet Accounts zunächst npm vorbereitet werden, um daraufhin die Anwendung installiert zu können:

su - moodlenet -s /bin/bash
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' > ~/.profile
source ~/.profile
npm i -g @moodlenet/ce-platform

Im Homeverzeichnis (/home/moodlenet) wird zur Konfiguration eine dotenv Datei erstellt. Das für die Variablen CRYPTO_PUBLIC_KEY und CRYPTO_PRIVATE_KEY benötigte Schlüsselpaar muss zuvor mittels openssl erzeugt werden. In der Konfigurationsdatei wird es einzeilig mit \n am Zeilenende hinterlegt.

openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem

vi /home/moodlenet/.env

# sample .env file

NODE_ENV=production
# DB
ARANGO_URL=http://localhost:8529

# ^HTTP config
#
HTTP_PORT=8080
PUBLIC_URL_PROTOCOL=http
#
# $HTTP config

# Webapp config
REACT_APP_CUSTOM_HEAD="<script>console.log('this env var string will be embedded as-is in HTML>HEAD')</script>"

# smtp url
#
# will work with simple user:password authentication only
# if using gmail you need to set a full-user-name if email is not in gmail domain
# SMTP=smtps://fullusername:password@smtp.gmail.com/?pool=true
# and probably need to enable "less secure apps access"
# https://myaccount.google.com/lesssecureapps
SMTP=smtps://fullusername:password@smtp.domain.com/?pool=true

# ^ CRYPTO config
#
# RSA keys
# https://gist.github.com/ygotthilf/baa58da5c3dd1f69fae9#gistcomment-2932501
CRYPTO_PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\n##<keyrows separated by \n>##\n-----END PUBLIC KEY-----"
CRYPTO_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n##<keyrows separated by \n>##\n-----END RSA PRIVATE KEY-----"
#
# $ CRYPTO keys

# Folder to save content static assets (images, resources ..)
STATICASSETS_FS_ROOT_FOLDER=/any/path/to/uploads/directory
# Max upload size in bytes - applies to images and resources
ASSET_UPLOADER_MAX_SIZE=10485760 # 10MB

#^SETUP VARS
#

# the following variables are necessary on first run as they will be used for initial DB population
# *** _all_ SETUP_* variables are mandatory for a correct installation ***
# they aren't required for subsequent system starts, though

# the domain hosting your MoodleNet installation
# in real world deployment would be something like: SETUP_ORGANIZATION_DOMAIN=my.example.domain.com
SETUP_ORGANIZATION_DOMAIN=localhost:${HTTP_PORT}

# an accessible email for the "organization user"
# super-admin will use this for authenticating as org-user
SETUP_ORGANIZATION_EMAIL=your.org.user@email.com

# following vars are used to fill the DB with your organization info,
# displayed in various contexts, from webapp to email notifications
SETUP_ORGANIZATION_NAME=My Awesome Organization
SETUP_ORGANIZATION_DESCRIPTION="My organization description\nmultiline"
SETUP_ORGANIZATION_SUBTITLE=My organization subtitle
# logos point to accessible images of any browser-supported mimetype
SETUP_ORGANIZATION_LOGO=https://url-to.any/logo.png
SETUP_ORGANIZATION_SMALL_LOGO=https://url-to.any/small-logo.svg
# whether a newly signed up user is marked as published or not
SETUP_2_0_1_NEW_USER_PUBLISHED=true
#
#$SETUP VARS

Sofern das Upload-Verzeichnis STATICASSETS_FS_ROOT_FOLDER existiert, lässt sich die Applikation bereits als moodlenet Benutzer im Homeverzeichnis des Kontos (/home/moodlenet) starten:

npx start-moodlenet-ce

Standardmässig ist MoodleNet über den HTTP Port 8080 erreichbar. Es bietet sich daher an einen Proxy wie nginx-proxy-manager vorzuschalten.

Als Administratoren-Konto kommt die unter SETUP_ORGANIZATION_EMAIL definierte E-Mail-Adresse zum Einsatz. Das Passwort lässt sich über die integrierte Passwort-Wiederherstellungsfunktion setzen. Voraussetzung dafür ist, dass der zu verwendende E-Mail-Server in der .env Datei korrekt konfiguriert wurde. Es kommt dabei nodemailer zum Einsatz, welcher eine verschlüsselte SMTP-Verbindung mit SASL Authentifizierung auf Port 465 aufbaut.

Um einen automatischen Start beim Systemstart zu gewährleisten, kann eine systemd-unit /etc/systemd/system/moodlenet.service erstellt werden.

vi /etc/systemd/system/moodlenet.service

[Unit]
Description=Moodlenet Web-Server

[Service]
Type=simple
User=moodlenet
WorkingDirectory=/home/moodlenet/
ExecStart=npx /home/moodlenet/.npm-global/bin/start-moodlenet-ce
StandardOutput=append:/home/moodlenet/logs/info.log
StandardError=append:/home/moodlenet/logs/error.log

[Install]
WantedBy=multi-user.target

Es bietet sich an für die Logdateien Logrotate einzurichten.

MoodleNet Webseite: https://moodle.com/moodlenet/