Install Moodle 4.3 on Ubuntu 22.04: A Step-by-Step Tutorial
Moodle, an acronym for Modular Object-Oriented Dynamic Learning Environment, is a robust open-source platform designed to facilitate online learning and course management. Developed by Martin Dougiamas in 2002, Moodle has evolved into one of the most widely used Learning Management Systems (LMS) globally.
Whether you are an educator, administrator, or learner, Moodle offers a robust and flexible environment for creating and participating in online courses. In this tutorial, we will learn how to install Moodle 4.3 with the following specifications:
- Vultr Cloud Server: 1 CPU, 1 GB RAM, 32 GB Storage
- Operating System: Ubuntu 22.04 LTS
- Subdomain: lms.aminlabs.my.id
- SSL: Let’s Encrypt
- Web Server: Apache
- PHP: PHP v8.1
- Database: MariaDB v10.6
- Moodle: Moodle v4.3.2
Note: Register here to get $100 free credit from Vultr.
Step 1: Update system packages
Connect to your server and ensure your system packages are up-to-date:
1 2 | apt update apt upgrade -y |
Note: This tutorial uses the root user.
Step 2: Install dependencies
Install the required dependencies for Moodle, Apache web server, PHP, and MariaDB database:
1 | apt install apache2 libapache2-mod-php php-mysql php-mbstring php-curl php-tokenizer php-xmlrpc php-soap php-zip php-gd php-xml php-intl mariadb-server -y |
Open the php.ini
configuration file:
1 | nano /etc/php/8.1/apache2/php.ini |
Activate and configure the following settings:
1 | max_input_vars = 5000 |
Step 3: Create a Database
Login to MariaDB:
1 | mysql |
Creating a database for Moodle:
1 2 3 4 | CREATE DATABASE lms_aminlabs DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL PRIVILEGES ON lms_aminlabs.* TO 'lms_aminlabs'@'localhost' IDENTIFIED BY 'secretpassword'; FLUSH PRIVILEGES; exit |
Step 4: Download Moodle
Download Moodle v4.3.2 from download.moodle.org:
1 | wget https://packaging.moodle.org/stable403/moodle-4.3.2.tgz |
Extract moodle-4.3.2.tgz
:
1 | tar xzvf moodle-4.3.2.tgz |
Move the moodle
directory to /var/www/lms.aminlabs.my.id/moodle-app
:
1 2 | mkdir /var/www/lms.aminlabs.my.id mv moodle /var/www/lms.aminlabs.my.id/moodle-app |
Create the moodle-data
directory:
1 | mkdir /var/www/lms.aminlabs.my.id/moodle-data |
Change user-group and permissions for the lms.aminlabs.my.id
directory.
1 2 | chown -R www-data:www-data /var/www/lms.aminlabs.my.id chmod -R 755 /var/www/lms.aminlabs.my.id |
Step 5: Configure Virtual Host
Create a virtual host configuration for the subdomain lms.aminlabs.my.id
:
1 | nano /etc/apache2/sites-available/lms.aminlabs.my.id.conf |
Insert the following virtual host configuration:
1 2 3 4 5 6 7 8 9 10 11 | <VirtualHost *:80> ServerName lms.aminlabs.my.id DocumentRoot /var/www/lms.aminlabs.my.id/moodle-app <Directory /var/www/lms.aminlabs.my.id/moodle-app> Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> ErrorLog /var/log/apache2/lms.aminlabs.my.id_error.log CustomLog /var/log/apache2/lms.aminlabs.my.id_access.log combined </VirtualHost> |
Enable the rewrite module, virtual host, and restart Apache:
1 2 3 | a2enmod rewrite a2ensite lms.aminlabs.my.id systemctl restart apache2 |
Check the status of the UFW firewall:
1 2 3 4 5 6 7 | ufw status Status: active To Action From -- ------ ---- 22/tcp ALLOW Anywhere 22/tcp (v6) ALLOW Anywhere (v6) |
If UFW is active, allow HTTP and HTTPS ports:
1 2 | ufw allow http ufw allow https |
Browse the subdomain to test whether Moodle is accessible:
Step 6: Configure HTTPS using Let’s Encrypt SSL
Install certbot:
1 | apt install certbot python3-certbot-apache -y |
Requesting an SSL certificate for the subdomain:
1 | certbot --non-interactive -m admin@aminlabs.my.id --agree-tos --no-eff-email --apache -d lms.aminlabs.my.id --redirect |
Example message displayed when the SSL certificate request is successful:
1 2 3 4 5 6 7 8 9 10 11 12 | Requesting a certificate for lms.aminlabs.my.id Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/lms.aminlabs.my.id/fullchain.pem Key is saved at: /etc/letsencrypt/live/lms.aminlabs.my.id/privkey.pem This certificate expires on 2024-04-02. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background. Deploying certificate Successfully deployed certificate for lms.aminlabs.my.id to /etc/apache2/sites-available/lms.aminlabs.my.id-le-ssl.conf Congratulations! You have successfully enabled HTTPS on https://lms.aminlabs.my.id |
Browse the subdomain to test the results of the HTTPS configuration:
Step 7: Web installation
Continue the installation in the web browser. Choose the language, for example English (en)
, then click the Next
.
Enter the path for the Moodle Data directory
, which is /var/www/lms.aminlabs.my.id/moodle-data
, then click the Next
:
Database driver, choose MariaDB (native/mariadb)
, then click Next
.
Enter database settings. Input Database name
, Database user
, and Database password
. Then click Next
:
Copyright notice, click Continue
to confirm.
Checking if the server environment meets all the requirements. Click Continue
if everything is OK
:
The installation is in progress, click Continue
when it’s finished:
Creating an admin account, then click Update profile
.
Configure Site home settings
, then click Save changes
:
The installation of Moodle has been completed. Site registration, click Skip
.
Congratulations! We have successfully installed Moodle 4.3 on Ubuntu 22.04. Let’s explore the platform’s features, customize our courses, and embark on a journey of seamless online learning with Moodle.
If you found this article helpful and would like to support my work, consider making a donation through PayPal. Your support helps me continue creating useful content and tutorials. Thank you!
Donate via PayPal: https://paypal.me/musaamin