Moodle is an open-source learning management system (LMS), probably the most popular and widely used of all those available.
Before starting, we recommend trying the service at https://moodle.org/demo, to see whether it meets your needs.
In this tutorial, we show you how to install Moodle on a server created from our LAMP image.
Prerequisites
• A server created from our LAMP image with at least 1 VCore and 2GB of RAM.
• A root password configured on your cloud server.
Update the System
Before starting, we recommend updating your system to the latest version. You can do this by running the following command:
# apt update && apt upgrade -yOnce your system has been updated, restart the server to apply the changes.
Download Moodle
Next, download Moodle from the github repository:
# git clone -b MOODLE_403_STABLE git://git.moodle.org/moodle.gitThis command clones a complete copy of the Moodle repository and switches to the 4.3 Stable branch.
Once the cloning process is complete, a directory named moodle will have been created with the repository contents:
# ls -l .
total 8
drwxr-xr-x 62 root root 4096 Apr 22 18:45 moodle
drwx------ 3 root root 4096 Apr 21 2022 snapCopy the files from the folder you just downloaded to the web server's main directory:
# cp -rT moodle/ /var/www/html/Delete the default file index.html:
# rm -f /var/www/html/index.htmlCreate the moodledata Directory
Moodle needs a directory to store files (for example, uploaded videos, temporary files, cache, session data, etc.). The web server needs write permissions for this directory.
# mkdir /var/www/moodledata
# chmod 0770 /var/www/moodledataCreate the Database
Now that you have downloaded Moodle and prepared it in your web server's directory, it is time to prepare the database Moodle will use. Open the mariadb client as the root user:
# mariadb
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 11.3.2-MariaDB-1:11.3.2+maria~ubu2204-log mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>Create a new empty database for Moodle with UTF8 encoding:
MariaDB [(none)]> CREATE DATABASE moodledb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;Next, create the user and password with the appropriate permissions to access the database. Make sure you enter a strong password for the database:
MariaDB [(none)]> CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'yourpassword';
MariaDB [(none)]> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodledb.* TO 'moodleuser'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;
Write down the password you assigned, because you will need it later during installation.
Next, exit the Mariadb shell with the following command:
MariaDB [(none)]> quit
ByeChange the Value of max_input_vars
First, you need to change the value of the PHP variable max_input_vars. You can do this by editing the configuration file /etc/php/8.2/apache2/php.ini:
nano /etc/php/8.2/apache2/php.iniFind the following line:
;max_input_vars = 1000
Uncomment it by deleting the semicolon at the beginning and change the value to 5000. It should look like this:
max_input_vars = 5000Save the changes with Ctrl+x, confirming that you want to save (y)es.
Next, restart the apache service to apply the change with:
systemctl restart apache2.serviceStart the Moodle Installation
Everything is now ready to start installing Moodle from your favorite web browser. Open a web browser and enter the URL http://ip-de-tu-servidor/install.php.
In the first installation step, choose the language you want to use during installation (it will also be used for the moodle site) and click the button Siguiente
Next, confirm that the installation paths are correct:
Select MariaDB (nativo/mariadb) as the database driver and click Siguiente:
In Ajustes de base de datos we will fill in Nombre de la base de datos, Usuario de la base de datos and Contraseña de la base de datos with the details we created earlier:
The fields Puerto de la base de datos and Socket Unix can be left empty. Click Siguiente to continue.
Confirm the terms and conditions by clicking Continuar:
On the next screen, Moodle checks whether certain minimum requirements are met to continue installing Moodle. If it finds any obstacles, you must resolve them before continuing with the installation. If you cannot continue because of the limit of the variable max_input_vars make sure you have followed the steps explained above to correct it.
The installation process then begins and its progress is displayed. It may take a while to finish installing all the modules. When installation is complete, click Continuar
The next page is for configuring Moodle's primary administrator account, which will have full control of the site. Make sure you enter a strong password and write it down for later use. Fill in the required details as shown below:
Once you have filled in the details, click Actualizar información personal
Next, fill in the basic information for the Moodle website, specifically Nombre completo del sitio and Nombre corto para el sitio. As the description states, the short name consists of one word without spaces:
In Nuevos ajustes - Ajustes de ubicación configure Zona horaria (in the example, we set it to Europa/Madrid). Also enter an email address for Contacto de soporte. You can leave the remaining settings at their default values. Click Guardar cambios to continue:
Installation is now complete, and the main Moodle dashboard is displayed with the Administrador user logged in:
Adjust Security Permissions
As a security measure, it is vitally important that the web server does not have write access to the Moodle directory. To do this, run the following command to adjust permissions:
# chown -R root /var/www/html
# chmod -R 0755 /var/www/htmlConclusion
Congratulations! You have successfully installed Moodle on the LAMP server.
Your Moodle website is now installed.
We hope this tutorial has helped you 🙂. Remember, if you have questions about this or any other issue related to your servers at Clouding, feel free to write to soporte@clouding.io We're here for whatever you need. Just ask us!