Install Moodle
Moodle is an LMS (Learning Management System). It's a very large and complex system, intended for setting up, creating, hosting, and scheduling learning sessions. These can be either or both online learning, or in class / in person style learning.
it's a powerful, open source system, and for a business in IT or an MSP, a valuable service to be able to rpovide. Particularly when considering you may need to train client users on best practices for better online security, privacy, and safe habits. Perhaps you have setup a new software for a client, and you need to provide training for their users on how to create an account, login, navigate, and perform the basic functions of the software.
Today we'll install moodle, and get you setup to provide e-Learning services.
What You'll Need
- A server or VM / Container to install the application software on.
- Docker and Docker Compose installed on the host server / VM / Container
- (optional) a domain / sub-domain to host your site at (e.g. myclasses.mygreatdomain.com)
- (optional) a Reverse Proxy to help get traffic onto the right service.
- About 20 minutes of your time.
What this tutorial is not:
This is not an in depth overview of how to configure or use the moddle software, either as an admin or student. It is massive, and far too much to cover in a video or online tutorial. Instead, I highly recommend you seek out other videos on more specific areas of Moodle, and definitely check out their extensive user and admin guides.
Installing Docker-CE (Community Edition) and Docker Compose
- Setup a server with a non-root, sudo user.
add user <username>
usermod -aG sudo <username>
or on CentOS, Fedora, RedHat usermod -aG wheel <username>
- Install Docker-CE and Docker Compose
curl https://get.docker.com | sh
- Add your non-root user to the docker group.
sudo usermod -aG docker <username>
- Log out and back in.
Setup for Our Moodle Install
- Create a folder structure for our Moodle application:
mkdir -p docker/moodle
- Inside the new folder, we need to create a file called "compose.yaml", and three folders.
cd docker/moodle
mkdir moodle_data
mkdir mariadb_data
mkdir moodledata_data
nano compose.yaml
- We need to add the code to our
compose.yaml
file now that it's created and open.
---
services:
mariadb:
image: docker.io/bitnami/mariadb:latest
container_name: moodle_mysql
environment:
- MARIADB_ROOT_PASSWORD=<a-long-strong-password>
- MARIADB_PASSWORD=<a-different-long-strong-password>
- MARIADB_USER=moodle
- MARIADB_DATABASE=moodle
- MARIADB_CHARACTER_SET=utf8mb4
- MARIADB_COLLATE=utf8mb4_unicode_ci
volumes:
- ./mariadb_data:/bitnami/mariadb
moodle:
image: docker.io/bitnami/moodle:4.5
container_name: moodle
ports:
- 80:8080
- 443:8443
environment:
- MOODLE_DATABASE_HOST=mariadb
- MOODLE_DATABASE_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=moodle
- MOODLE_DATABASE_NAME=moodle
- ALLOW_EMPTY_PASSWORD=no
- MOODLE_DATABASE_PASSWORD=<a-different-long-strong-password> # <-- same as the MARIADB_PASSWORD from the first section.
- MOODLE_HOST=<name.mygreatdomain.org>
- MOODLE_REVERSEPROxY=true # <-- if you're using a reverse proxy make it true, otherwise false
- MOODLE_SSLPROXY=true # <-- if you are using LetsEncrypt through your proxy, again make it true, otherwise false
- MOODLE_SMTP_HOST=<smtp.somemailprovider.com>
- MOODLE_SMTP_PORT=587
- MOODLE_SMTP_USER=<leanring@somemailprovider.com>
- MOODLE_SMTP_PASSWORD=<some-email-password-for-the-user-above>
- MOODLE_SMTP_PROTOCOL=tls
- MOODLE_LANG=en
- MOODLE_USERNAME=<admin_username>
- MOODLE_PASSWORD=<admin_password>
volumes:
- ./moodle_data:/bitnami/moodle
- ./moodledata_data:/bitnami/moodledata
depends_on:
- mariadb
In the above file, there are multiple values you'll need to change, and make unique to your installation and setup. I have marked those fields by surrounding the value in less than and greater than signs ( "<" and ">").
In a few cases I also added a comment about the values, in case you need to adjust them for some reason. Finally, and most importantly, make sure the values for MARIADB_PASSWORD in the first section and MOODLE_DATABASE_PASSWORD in the second section match exactly. This is important for the application to function.
When done setting your values, save the file with CTRL + O, then press Enter to confirm, and exit the file with CTRL + X.
Now let's pull our images down from dockerhub or github.
docker compose pull
Once pulled, we'll start our virtual machines (containers) with
docker compose up -d && docker compose logs -f
The above is a set of two commands concatenated with two ampersands (&&). The first command tells docker compose to start the containers from the images we pulled down, and run those containers in detached mode (-d). The second command tells docker compose to show us the logs when the containers start, and follow (-f) the output as it's generated.
When we are done viewing the logs, we can use CTRL + C, to stop seeing them being output to the screen.
Support My Channel and Content