Get started with Moodle


At Rimuhosting, we support a wide range of Moodle deployments — from simple academic setups to complex, high-availability platforms.

This guide walks you through a clean and secure installation of Moodle 4.5 LTS, the latest long-term support release. Whether you’re launching a development instance, staging site, or preparing for full production, this setup gives you a solid and scalable foundation to build on.

What is Moodle?

Moodle is a free, open-source learning management system (LMS) used to deliver flexible and scalable online education.

It’s trusted by institutions worldwide because it’s customizable, community-driven, and doesn’t lock you into a commercial platform. Moodle supports everything from simple course delivery to complex learning environments with custom roles, interactive quizzes, progress tracking, mobile access, and plugin-based extensibility.

As of now, the latest Long-Term Support (LTS) release is Moodle 4.5, which will receive security updates through November 2026. The next LTS release is expected in October 2026.

Requirements

Hardware Recommendations
Moodle is a resource-intensive and hardware-demanding application. You can start spinning up a VM (https://rimuhosting.com/order/v2orderstart.jsp) with the following recommended specs:

  • RAM: Minimum 4GB; 8GB or more recommended for production environments.
  • Disk: Minimum 10GB SSD
  • CPU: Fast multi-core processor

OS and LAMP Stack Preparation

  • PHP version: PHP 8.1 – PHP 8.3
  • MariaDB: 10.6.7 or newer
# This example was performed on Ubuntu 24.04. Debian is also a good option 
apt update &&  apt upgrade -y

# Install the latest Apache, MariaDB, PHP and required extensions if not available
# If using PHP 8.1 or 8.2, install the phpX.Y-sodium extension separately
apt install -y apache2 mariadb-server php libapache2-mod-php php-{cli,mysql,xmlrpc,soap,intl,gd,xml,mbstring,curl,zip,opcache} git unzip

# Check the installed version
php -v
mariadb --version

Step-by-step guidance

Download Moodle and Set Permissions

mkdir -p /var/www
cd /var/www
git clone -b MOODLE_405_STABLE git://git.moodle.org/moodle.git moodle

Create the Moodle Database

mysql -u root

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'YourPassword';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Create moodledata Directory
moodledata is used to store user-uploaded content, cache, and other runtime data.

# It must be writable by the web server and should be stored outside the core Moodle code directory.
mkdir /var/www/moodledata
chown -R www-data:www-data /var/www/moodledata
chmod -R u=rwx,g=rwx,o= /var/www/moodledata

Apache Virtual Host Configuration
Create the Apache site config in /etc/apache2/sites-available/moodle-example.com.conf:

<VirtualHost *:80>
    ServerName moodle-example.com
    DocumentRoot /var/www/moodle    
    <Directory /var/www/moodle>            
       Options +FollowSymLinks
       AllowOverride All
       Require all granted
    </Directory>
   ErrorLog ${APACHE_LOG_DIR}/moodle_error.log
   CustomLog ${APACHE_LOG_DIR}/moodle_access.log combined
</VirtualHost>

Enable the site and required modules:

a2enmod rewrite php8.3
a2ensite moodle-example.com.conf
a2dissite 000-default
systemctl reload apache2

Configure PHP Settings
This is a minimal single-site setup with Apache mod_php that would work well with small to medium Moodle setups. For better performance under high load, consider using php-fpm. Edit php.ini for both Apache and cli to make sure these settings:

nano /etc/php/8.3/apache2/php.ini
# 128M is the minimum; 256M is recommended 
memory_limit = 256M
# This is a must-do according to the server requirements
max_input_vars = 5000
# These restrict the maximum file size that can be uploaded
upload_max_filesize = 100M
post_max_size = 100M

nano /etc/php/8.3/cli/php.ini
# Match CLI PHP settings with Apache to avoid issues during Moodle CLI operations (e.g., cron or upgrade scripts)
max_input_vars = 5000
memory_limit = 256M
upload_max_filesize = 100M
post_max_size = 100M

# Then restart Apache
systemctl restart apache2

Install Moodle

sudo -u www-data php /var/www/moodle/admin/cli/install.php \
--lang=en \
--wwwroot=http://moodle-example.com \
--dataroot=/var/www/moodledata \
--dbtype=mariadb --dbhost=localhost \
--dbname=moodle --dbuser=moodleuser --dbpass=YourPassword \
--fullname="My Moodle Site" --shortname="Moodle" \
--adminuser=admin --adminpass=StrongPassword \
--adminemail=admin@example.com \
--agree-license --non-interactive

chown -R root:root /var/www/moodle
timedatectl set-timezone Pacific/Auckland

Enable HTTPS
Secure your Moodle site with HTTPS. We’ll use Certbot to obtain a free Let’s Encrypt SSL certificate.

apt install -y certbot python3-certbot-apache
certbot --apache -d moodle-example.com
systemctl restart apache2

config.php
Inspect /var/www/moodle/config.php and verify:

$CFG->dbtype = 'mariadb';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'moodleuser';
$CFG->dbpass = 'YourPassword';
$CFG->prefix = 'mdl_';
$CFG->wwwroot = 'https://moodle-example.com'; 
$CFG->dataroot = '/var/www/moodledata';
$CFG->admin = 'admin'; // URL like /admin
$CFG->directorypermissions = 02777; // for moodledata

Set secure permissions:

chown root:root /var/www/moodle/config.php
chmod 644 /var/www/moodle/config.php

Set up Cron Job
Moodle requires a background cron job to process tasks.

echo "* * * * * www-data /usr/bin/php /var/www/moodle/admin/cli/cron.php >/dev/null 2>&1" | tee -a /etc/crontab

Outgoing Mail
Moodle must be able to send emails for account confirmation, password reset, and notifications. In this example, we will configure local Postfix as the outgoing mail server.

# Install a simple local MTA to allow Moodle to send emails
apt install -y postfix

Edit /etc/postfix/main.cf and ensure the following:

myhostname = moodle-example.com
inet_interfaces = all
inet_protocols = ipv4

Restart postfix:

systemctl restart postfix

For better email delivery, consider configuring domain authentication protocols like SPF, DKIM, DMARC, and PTR records.

Post-install
Now log in at https://moodle-example.com with the admin account. Go to Site administration and review:
-> Environment check
-> Timezone and language
-> SMTP settings
-> Theme, password policy, session timeout, etc.

With Moodle 4.5 LTS now installed and secured, you’ve got a stable foundation to build on — whether that means customising themes, extending features with plugins, or fine-tuning performance.

In addition to setting up new Moodle instances, if you’re migrating an older Moodle site or planning an upgrade, feel free to submit a support ticket, and we’re happy to support.

# Documentation reference: https://docs.moodle.org/405/en/Installation


Leave a Reply