11.12.2024

Installing Moodle on an Ubuntu 20.04 server

What is Moodle ?

Moodle is a learning management system.

Essentially, it's an easy way for schools and teachers to give students marks, check their own work and keep track of their grades.

And it's all online. If you've ever worked with something like an online whiteboard or taken part in a course, then you know what we're talking about.

Why moodle? First of all for our demonstration purposes it was perfect, it has all the features we were looking for and at the end of the day, the license for moodle is free up to a certain number of users. The limit is on having more than 5,000 users connected to your moodle, so if you have fewer people then you are not required to pay for a license.

Extensive communication is one of the strengths of moodle:

Additional function modules can be installed as needed. Moodle can be used for:

Preparing the system to install and configure moodle:

In order for moodle to work, you will need to install apache web server,

this step will be skipped as we use an out-of-the-box solution when we set up the server. On our website we have instructions on how to install and configure apache.

On serverspace you can create a server with apache already installed.

Because apache was installed during the creation of the server, we can access our ip address in the webstring and we will see this message that apache is up and running.

Update our machine using the commands below:

sudo apt-get update && sudo apt-get upgrade

It is required to install mysql client and server library, also don't forget php library to communicate with apache.

sudo apt install apache2 mysql-client mysql-server php7.4 libapache2-mod-php

After this, additional software will need to be installed.
This will take longer because you need to install the multi-layered compatibility of the php, mysql,
prerequisite libraries to make them work together.

sudo apt install graphviz aspell ghostscript clamav php7.4-pspell php7.4-curl php7.4-gd php7.4-intl php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-ldap php7.4-zip php7.4-soap php7.4-mbstring git -y

Do not forget to restart the apache web server:

sudo service apache2 restart

To check the status of the web server, type the command below:

sudo systemctl status apache2

Go to the "opt" directory and clone what we need:

cd opt

Cloning data to our server:

sudo git clone git://git.moodle.org/moodle.git

Once installed, navigate to the folder where we will download the desired files.(When we're done, we will simply move the folder to the directory we want)

:

cd moodle

List available branches, if needed:

sudo get branch -a

After that, select a particular branch and install it:

sudo git branch --track MOODLE_39_STABLE origin/MOODLE_39_STABLE

Check the installed version of Moodle on our server:

sudo git checkout MOODLE_39_STABLE

Copy the directory where we downloaded all the data (in our case /opt/moodle, to the apache directory.

Example command:

sudo cp -R /opt/moodle /var/www/html/

Let's create a folder where the moodle data will be stored:

sudo mkdir /var/moodledata

Do not forget to give it certain permissions:

sudo chown -R www-data /var/moodledata
sudo chmod -R 777 /var/moodledata
chmod ugoa=rwx /var/moodledata
sudo chmod -R 0755 /var/www/html/moodle

This folder will store lesson documents, not configuration files!

Preparing the Database:

The following configuration is only for those with MySQL version below 8.0, you can check the MySQL version with the command:

mysql --version

Configure the MySQL configuration file

Fore configure config you could use any text editor as you like, in our case it will be "nano".

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

It's required to add 3 lines of code at the end of the configuration file,
see how it's implemented in our case:

default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda

Save the configuration file and restart the database.

Creating a database

The command below we connects to mysql:

mysql -u root -p

Turn on support for 4 byte UTF 8:

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Create a user for the database:

create user serverspace@'localhost' IDENTIFIED BY 'P@ssw0rd';

Grant full rights for our user:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO serverspace @'localhost';

Exit MySQL:

quit

Grant access rights to the "moodle" folder:

sudo chmod -R 777 /var/www/html/moodle

Restart your server:

systemctl restart apache2

Completing the installation, setting up Moodle

After restarting, further configuration can be done from within the web interface:

If you have done everything correctly,
open your browser and type the ip address of your server into the web interface,
after it add the following " x.x.x.x/moodle/install.php".
You should get a window like this:

Then follow the instructions on the screen and set it up the way you want it!
Don't forget to change the path to your data folder:

In the following screenshot, specify the login and password for your created database.

Next you will need to wait for the installation to complete.

After the correct installation you will have the admin panel open.

Conclusion

This publication will make it easy for you to install moodle and get it up and running for your own needs.

Do not be afraid to check out the moodle tutorial, you will find many unique information on how to fine tune your moodle service.