Moodle LMS Administration

Moodle 5.0 Stable · Full Spectrum Deployment Guide

Every command, every fix, every edge case covered. Provision and deploy a completely secured Moodle 5.0 Stable environment on Apache, MariaDB, and PHP 8.1. Includes dedicated 100GB persistent volume storage configuration, SSL, Cron daemon, and email relays.

Pipeline H: LAMP Deployment Stages

Stage 1
LAMP Stack
Ubuntu & PHP 8.1
Stage 2
MariaDB Setup
utf8mb4_unicode_ci
Stage 3
Storage Partition
100GB sdb1 Mount
Stage 4
SSL VirtualHost
Let's Encrypt

🚀 ULTIMATE 14‑STEP DEPLOYMENT PIPELINE

1. Base OS & full LAMP stack

Package Selection Rationale
Selecting custom libraries guarantees support for Moodle's dependencies: gd is used for user avatars, xml/mbstring for language localization, and intl for character conversion operations.
bash · repository and package setup
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 mariadb-server mariadb-client -y
sudo apt install php8.1 php8.1-cli php8.1-common php8.1-mysql php8.1-xml php8.1-curl php8.1-gd php8.1-intl php8.1-mbstring php8.1-zip php8.1-soap php8.1-bcmath libapache2-mod-php8.1 -y
sudo apt install git nano cron sendmail certbot python3-certbot-apache unzip rsync -y
sudo a2enmod rewrite ssl headers
sudo systemctl restart apache2
Potential Issue
If a package like libapache2-mod-php8.1 is missed, Apache will render raw PHP code as text instead of executing it. Always verify Apache handles PHP via php -m.

2. MariaDB secure + Database/User creation

Collation Specifications
Moodle requires strict database collation parameters. If you do not use utf8mb4_unicode_ci, Moodle will fail during installations, throwing character set incompatibility exceptions.
sql · DB provisioning
CREATE DATABASE moodle_demo CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleDemo2026'@'localhost' IDENTIFIED BY '2026PassDemo!!';
GRANT ALL PRIVILEGES ON moodle_demo.* TO 'moodleDemo2026'@'localhost';
FLUSH PRIVILEGES;
-- run mysql_secure_installation after

3. PHP.ini tuning (upload, execution, memory)

Performance Rationale
Tuning these values ensures large SCORM course packages (often exceeding 100MB) can upload without timeouts. Standard PHP settings (e.g. 2M upload limit) will crash course uploads.
bash · php.ini edit
sudo nano /etc/php/8.1/apache2/php.ini
# Set mandatory parameters:
upload_max_filesize = 1080M
post_max_size = 1080M
max_execution_time = 3600
memory_limit = 512M
max_input_vars = 5000
max_input_time = 300
date.timezone = UTC
sudo systemctl restart apache2

4. Clone Moodle 5.0 (MOODLE_500_STABLE)

Path Specifics
Ensure you clone into the target directory `moodl_ulo2026Demo` exactly. Setting the correct ownership for `www-data` prevents runtime write issues.
bash · git commands
cd /var/www
sudo git clone -b MOODLE_500_STABLE git://git.moodle.org/moodle.git moodl_ulo2026Demo
cd moodl_ulo2026Demo
sudo chown -R www-data:www-data /var/www/moodl_ulo2026Demo
sudo chmod -R 755 /var/www/moodl_ulo2026Demo

5. 100GB Data Disk Partition & Format (sdb1)

Storage Setup
Partitioning an external 100GB storage disk allows course content and logs to grow without filling up the system volume. Mounting via UUID in `/etc/fstab` ensures persistence on boot.
bash · disk partitioning
sudo fdisk /dev/sdb   # n (new) → p (primary) → Enter → Enter → w
sudo mkfs.ext4 /dev/sdb1
sudo mkdir -p /var/moodledata
sudo mount /dev/sdb1 /var/moodledata
sudo blkid /dev/sdb1   # copy UUID
echo "UUID=your-uuid-here /var/moodledata ext4 defaults,noatime 0 2" | sudo tee -a /etc/fstab
sudo chown -R www-data:www-data /var/moodledata
sudo chmod -R 770 /var/moodledata

6. config.php creation (full production)

Dataroot Policy
Your config.php maps database access keys. Note that dataroot directory MUST be placed outside your public web server folder to secure uploaded coursework.
php · config.php
cd /var/www/moodl_ulo2026Demo
sudo cp config-dist.php config.php
sudo nano config.php
# PASTE CONFIGURATION:
$CFG->dbtype    = 'mariadb';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle_demo';
$CFG->dbuser    = 'moodleDemo2026';
$CFG->dbpass    = '2026PassDemo!!';
$CFG->prefix    = 'mdl_';
$CFG->wwwroot   = 'https://classroom.demodemo.com';
$CFG->dataroot  = '/var/moodledata';
$CFG->directorypermissions = 02775;
$CFG->disablelogintoken = true;
$CFG->releasetype = 'stable';

7. Apache VirtualHost (HTTP & SSL readiness)

Apache Vhost Setup
Setup the target VirtualHost map pointing to `/var/www/moodl_ulo2026Demo`. This serves requests targeted to `classroom.demodemo.com`.
bash · sites config
sudo nano /etc/apache2/sites-available/moodle-ulo2026demo.conf
# Paste VirtualHost block below
sudo a2ensite moodle-ulo2026demo.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
apache · vhost
<VirtualHost *:80>
    ServerName classroom.demodemo.com
    DocumentRoot /var/www/moodl_ulo2026Demo
    <Directory /var/www/moodl_ulo2026Demo>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

8. Let's Encrypt SSL + auto-renewal

SSL Offloading
SSL is mandatory. Certbot will rewrite your VirtualHost to listen on port 443 and auto-inject SSL certificate directories.
bash · certbot
sudo certbot --apache -d classroom.demodemo.com
sudo systemctl status certbot.timer
sudo certbot renew --dry-run
# Force HTTPS redirect enabled by certbot

9. Cron (every minute) + background queue

Cron Job Policy
Moodle cannot operate without background cron tasks. Triggering cron every minute processes asynchronous emails, completes course registrations, and handles gradebook refreshes.
bash · crontab schedule
sudo crontab -u www-data -e
# Add:
* * * * * /usr/bin/php /var/www/moodl_ulo2026Demo/admin/cli/cron.php > /dev/null
sudo systemctl enable cron
sudo -u www-data php /var/www/moodl_ulo2026Demo/admin/cli/cron.php

10. Sendmail & email configuration

Notification Systems
Postfix or Sendmail relays local mail requests. Running sendmailconfig configures default local delivery routes.
bash · SMTP tools
sudo apt install sendmail -y
sudo sendmailconfig  # yes all defaults
# test: echo "Subject: test" | sendmail admin@demodemo.com

11. Bind mount alternative & fstab hardening

Directory Mounts
Hardening mount parameters protects volumes. Disabling directory updates check (via `noatime`) saves huge disk write cycles.
bash · mount check
# optional but robust: ensure /var/moodledata is always mounted
sudo umount /var/moodledata || true
sudo mount -a
# verify: df -h | grep moodledata
# extra bind if needed: /mnt/moodledata /var/moodledata none bind 0 0

12. Clean stuck tasks & backup controllers (restore fix)

Restore Deadlocks
If a restore task is aborted, SQL transaction locks are held. Deleting controllers and clearing local file storage cache resolves deadlocks immediately.
sql & bash
mysql -u root -p moodle_demo -e "DELETE FROM mdl_task_adhoc WHERE classname LIKE '%restore%';"
mysql -u root -p moodle_demo -e "DELETE FROM mdl_backup_controllers;"
sudo rm -rf /var/moodledata/temp/backup/* /var/moodledata/cache/* /var/moodledata/localcache/*

13. Final permissions & apache hardening

Security Policies
Strict permissions prevent security vulnerabilities. `755` permissions for codebase folders and `770` for dataroot secure server file integrity.
bash · permissions
sudo chown -R www-data:www-data /var/moodledata /var/www/moodl_ulo2026Demo
sudo chmod -R 755 /var/www/moodl_ulo2026Demo
sudo chmod -R 770 /var/moodledata
sudo systemctl restart apache2 mariadb
sudo apache2ctl configtest

14. Validation & Health Dashboard

Final Checklists
Verify server schema mapping and cron execution tasks are active. The HTTP status check on domain confirms server availability.
bash · diagnostic validation
php /var/www/moodl_ulo2026Demo/admin/cli/check_database_schema.php
sudo -u www-data php /var/www/moodl_ulo2026Demo/admin/cli/cron.php --force
curl -I https://classroom.demodemo.com

Core Config Vault

config.php
$CFG->dbname='moodle_demo'; $CFG->dbuser='moodleDemo2026';
$CFG->dbpass='2026PassDemo!!'; $CFG->wwwroot='https://classroom.demodemo.com';
$CFG->dataroot='/var/moodledata'; $CFG->disablelogintoken=true;
Apache SSL (443)
<VirtualHost *:443>
    ServerName classroom.demodemo.com
    DocumentRoot /var/www/moodl_ulo2026Demo
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/classroom.demodemo.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/classroom.demodemo.com/privkey.pem
</VirtualHost>
www-data crontab
* * * * * /usr/bin/php /var/www/moodl_ulo2026Demo/admin/cli/cron.php > /dev/null

Requirements Baseline

PHP Opcache tuning:

opcache.enable=1; opcache.memory_consumption=256; opcache.max_accelerated_files=10000

MariaDB Optimization:

innodb_buffer_pool_size=1G

Performance Diagnostics

  • Moodle cron stats:
    php admin/cli/cron.php --verbose
  • Disk inode check:
    df -i /var/moodledata
  • Redis session setup:
    sudo apt install redis php8.1-redis