Moodle
On this page:
Moodle is the largest and most popular open-source eLearning platform.
Prerequisites
Before installing Moodle, make sure all the components specified in the Moodle Server Configuration page are installed and properly configured.
Installation Steps
To execute Docker commands, a user with sudo privileges is required. If the root user is accessible, there is no need to add the ‘sudo’ instruction.
To deploy a containerized Moodle using Docker, follow these steps:
Create a Docker Compose file in the /opt directory.
cd /opt mkdir moodle cd /moodle nano docker-compose.yml
Copy the following text inside the file. The Docker images belong to a company named bitnami.
# Copyright Broadcom, Inc. All Rights Reserved. # SPDX-License-Identifier: APACHE-2.0 services: postgresql: image: docker.io/bitnami/postgresql:15 environment: # ALLOW_EMPTY_PASSWORD is recommended only for development. #- ALLOW_EMPTY_PASSWORD=yes - POSTGRESQL_USERNAME=moodleuser - POSTGRESQL_PASSWORD=<db_password> - POSTGRESQL_DATABASE=moodle #- MARIADB_CHARACTER_SET=utf8mb4 #- MARIADB_COLLATE=utf8mb4_unicode_ci volumes: - 'postgresql_data:/bitnami/postgresql' moodle: image: docker.io/bitnami/moodle:4.1 ports: - '8080:8080' - '8443:8443' environment: - MOODLE_DATABASE_TYPE=pgsql - MOODLE_DATABASE_HOST=172.18.0.2 - MOODLE_DATABASE_PORT_NUMBER=5432 - MOODLE_DATABASE_USER=moodleuser - MOODLE_DATABASE_NAME=moodle - MOODLE_DATABASE_PASSWORD=<db_password> - MOODLE_HOST=<server_hostname> - MOODLE_REVERSEPROXY=true - MOODLE_SSLPROXY=true # ALLOW_EMPTY_PASSWORD is recommended only for development. #- ALLOW_EMPTY_PASSWORD=yes volumes: - 'moodle_data:/bitnami/moodle' - '/home/ubuntu/moodledata:/bitnami/moodledata' depends_on: - postgresql volumes: postgresql_data: driver: local moodle_data: driver: local
Make sure to replace values where needed. E.g. Replace <db_password> with the actual password for the moodle database user.
Note one of the moodle volumes is pointing to a folder named moodledata located in /home/ubuntu/moodledata
Some of Moodle’s settings and files are not saved on the database, instead there is a folder named moodledata which contains many of these things. It is necessary to download a copy of this folder and upload it to the new server.
Access https://fundo.impilo.app/ server, create a .zip of the moodledata folder and download it using a tool like FileZilla. The moodledata folder is located in /opt/moodledata
sudo zip -r moodledata.zip moodledata
Upload the .zip to the new server, and unzip it.
Change the docker-compose.yml file, type the correct path to the moodledata folder
Create the container using Docker Compose
docker compose up -d
Install Moodle plugins.
Impilo Moodle instance has a total of 6 plugins used to accomplish different functionalities. Start by downloading each of them. Download the file to your PC and then upload to the server using a tool like FileZilla or use the wget command and copy the URL from the plugin’s download button:
To install the plugins, just copy the downloaded folder into their respective paths in the Moodle folder.
Unzip the file
unzip plugin.zip
Copy custom certificate to the mod/ folder
docker cp /path/to/customcert CONTAINERID:/bitnami/moodle/mod/customcert
Enter into the container, navigate to the plugin folder and change its owner and permissions
docker exec -ti -u root CONTAINERID bash cd /bitnami/moodle/mod chown -R daemon:root customcert/ chmod -R 775 customcert/
Copy event trigger to the tool/ folder, and repeat step iii. for this plugin.
docker cp /path/to/trigger CONTAINERID:/bitnami/moodle/admin/tool/trigger
Copy autocomplete input to the field/ folder, and repeat step iii. for this plugin.
docker cp /path/to/autocomplete CONTAINERID:/bitnami/moodle/user/profile/field/autocomplete
Copy academi to the theme/ folder, and repeat step iii. for this plugin.
docker cp /path/to/academi CONTAINERID:/bitnami/moodle/theme/academi
Copy static pages to local/ folder, and repeat step iii. for this plugin.
docker cp /path/to/staticpage CONTAINERID:/bitnami/moodle/local/staticpage
Copy moodle analytics to the local/ folder, and repeat step iii. for this plugin.
docker cp /path/to/analytics CONTAINERID:/bitnami/moodle/local/analytics
Stop Moodle container
docker ps docker stop <container-ID>
Enter to the database container
docker exec -ti -u root <container-ID> bash
Access the PostgreSQL database
psql -U moodleuser -d moodle
Delete Moodle’s database and create it again
\c postgres DROP DATABASE moodle; CREATE DATABASE moodle WITH OWNER moodleuser; \q exit
Download a backup of https://fundo.impilo.app/ Moodle’s database. Daily backups can be found at the S3 bucket named ‘backups-psh-s3’, located in the PSI Bahmni AWS account.
Upload the database backup to the server using FileZilla or a similar tool.
Copy the backup to the database container
docker cp /path/to/backup.sql.gz CONTAINERID:/bitnami
Enter the container again, and go to the bitnami folder where the backup file was copied. Decompress the file:
gzip -d backup.sql.gz
Proceed to restore the backup:
psql -d moodle -f backup.sql -U moodleuser
Start the Moodle container again
docker start CONTAINERID
Moodle homepage should display when entering the domain. See Moodle Server Configuration for information on how to configure nginx.