/
Moodle

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:

  1. Create a Docker Compose file in the /opt directory.

    cd /opt mkdir moodle cd /moodle nano docker-compose.yml
  2. 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

  1. 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.

    1. 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
    2. Upload the .zip to the new server, and unzip it.

    3. Change the docker-compose.yml file, type the correct path to the moodledata folder

  2. Create the container using Docker Compose

    docker compose up -d
  3. Install Moodle plugins.

    1. 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:

      1. Custom Certificate v4.1.4

      2. Event Trigger v2024031401

      3. Autocomplete Input v2022071900

      4. Academi Theme v4.3.3

      5. Static Pages v4.1-r3

      6. Moodle Analytics Plugin release 1.0

    2. To install the plugins, just copy the downloaded folder into their respective paths in the Moodle folder.

      1. Unzip the file

        unzip plugin.zip
      2. Copy custom certificate to the mod/ folder

        docker cp /path/to/customcert CONTAINERID:/bitnami/moodle/mod/customcert
      3. 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/
      4. 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
      5. 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
      6. Copy academi to the theme/ folder, and repeat step iii. for this plugin.

        docker cp /path/to/academi CONTAINERID:/bitnami/moodle/theme/academi
      7. Copy static pages to local/ folder, and repeat step iii. for this plugin.

        docker cp /path/to/staticpage CONTAINERID:/bitnami/moodle/local/staticpage
      8. Copy moodle analytics to the local/ folder, and repeat step iii. for this plugin.

        docker cp /path/to/analytics CONTAINERID:/bitnami/moodle/local/analytics
  4. Stop Moodle container

    docker ps docker stop <container-ID>
  5. Enter to the database container

    docker exec -ti -u root <container-ID> bash
  6. Access the PostgreSQL database

    psql -U moodleuser -d moodle
  7. Delete Moodle’s database and create it again

    \c postgres DROP DATABASE moodle; CREATE DATABASE moodle WITH OWNER moodleuser; \q exit
  8. 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.

  9. Upload the database backup to the server using FileZilla or a similar tool.

  10. Copy the backup to the database container

    docker cp /path/to/backup.sql.gz CONTAINERID:/bitnami
  11. Enter the container again, and go to the bitnami folder where the backup file was copied. Decompress the file:

    gzip -d backup.sql.gz
  12. Proceed to restore the backup:

    psql -d moodle -f backup.sql -U moodleuser
  13. Start the Moodle container again

    docker start CONTAINERID
  14. Moodle homepage should display when entering the domain. See Moodle Server Configuration for information on how to configure nginx.

Related content