Moodle 5.x introduces a significant architectural change: the public/ directory pattern. Unlike previous versions where the entire Moodle root was exposed to the web server, Moodle 5+ requires your web root to point to the public/ subdirectory. This guide covers a complete production-ready tuning stack that respects this new structure while delivering sub-second page loads under heavy concurrent load.

Prerequisites

  • Ubuntu 24.04 LTS (server edition)
  • MariaDB 10.11+
  • Moodle 5.2+ installed at /var/www/moodle
  • Apache 2.4+
  • Root or sudo access
  • Assumed paths:
    • Moodle source: /var/www/moodle
    • Web root (DocumentRoot): /var/www/moodle/public
    • Moodle data: /var/moodledata
    • Moodle config: /var/www/moodle/config.php

The Moodle 5.x Public Directory

In Moodle 5+, never point Apache’s DocumentRoot to /var/www/moodle. Always point it to /var/www/moodle/public. The config.php file lives one level above the web root, which prevents direct HTTP access to sensitive credentials.

Share this post