Moodle is the world’s most popular, robust, free, and open-source online learning (e-learning) management platform built for web and mobile. It offers a wide range of activities and educational tools that enable schools, universities, and related institutions to offer students a flexible learning platform any time, anywhere, without interruption to their course and curriculum.
Some of its general features include a modern, easy-to-use interface, personalized dashboard, collaborative tools and activities, all-in-one calendar, convenient file management, simple intuitive text editor, notifications, and track progress.
Importantly, Moodle is also highly extensible using over a thousand plugins that support extra activities, blocks, themes, and so much more.
In this article, you will learn how to install the latest version of the Moodle Learning Platform with NGINX and MySQL/MariaDB database on Ubuntu 20.04 and older versions.
Once you have installed the LEMP stack on the Ubuntu server, you can proceed further to set up Moodle on the server as explained below.
1. For users to access your Moodle instance you need to create a subdomain for it, thus, you need to create a DNS A
record to achieve this. For this guide, our test domain is testprojects.me
, so we need to create a subdomain, for example, learning.testprojects.me
.
So, log into your domain registrar’s web console and access your domain’s advanced settings, click Add New Record of type A
, a host should be learning
(or any word of your choice), and value should be the public IP address of your Ubuntu server.
Create DNS A Record for Moodle Application
2. Next, you need to install PHP extensions and libraries required by Moodle using the apt package manager as shown.
$ sudo apt update
$ sudo apt install php-common php-iconv php-curl php-mbstring php-xmlrpc php-soap php-zip php-gd php-xml php-intl php-json libpcre3 libpcre3-dev graphviz aspell ghostscript clamav
3. Next, create a database for your Moodle system. Log in to the MySQL database administration shell and create the database as shown:
$ sudo mysql
MariaDB [(none)]> CREATE DATABASE moodle;
MariaDB [(none)]> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'moodleadmin'@'localhost' IDENTIFIED BY 'Secur3P@zzwd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> quit;
4. As mentioned earlier, for this guide, we will download and install the latest version Moodle (version 3.9 at the time of writing). Run the following wget command to grab the Moodle package and use the tar command to extract it respectively. Then use the ls command to confirm that the moodle directory exists under /var/www/html/ as shown.
$ wget -c https://download.moodle.org/download.php/direct/stable39/moodle-latest-39.tgz
$ sudo tar -zvxf moodle-latest-39.tgz -C /var/www/html/
$ ls /var/www/html/
5. Next, set appropriate permissions on the Moodle directory by running the following commands.
$ sudo chown www-data:www-data -R /var/www/html/moodle
$ sudo chmod 775 -R /var/www/html/moodle
6. Next, create the Moodle data directory, a place where Moodle can save uploaded files and set its permissions as shown.
$ sudo mkdir -p /var/moodledata
$ sudo chmod 775 -R /var/moodledata
$ sudo chown www-data:www-data -R /var/moodledata
7. Then create the Moodle main configuration file from the sample configuration file provided with the package, open it.
$ cd /var/www/html/moodle/
$ sudo cp config-dist.php config.php
$ sudo vim config.php
Lok for the database configuration section, then configure the database where all Moodle data will be stored, as shown in the following screenshot:
$CFG->dbtype = 'mariadb'; // 'pgsql', 'mariadb', 'mysqli', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native'; // 'native' only at the moment
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname = 'moodle'; // database name, eg moodle
$CFG->dbuser = 'moodleadmin'; // your database username
$CFG->dbpass = 'Secur3P@zzwd'; // your database password
$CFG->prefix = 'mdl_'; // prefix to use for all table names
Configure Moodle Database Settings
Also, configure the Moodle website location as well as the location of the Moodle data directory as shown.
$CFG->wwwroot = 'http://learning.testprojects.me';
$CFG->dataroot = '/var/moodledata';
Configure Moodle Website
Save the close the file. Then configure NGINX to server your Moodle site as described in the next section.
#cms #open source #ubuntu #moodle learning platform #ubuntu tips