21.8 C

How to install Moodle with Ubuntu 20.04 LTS.

The COVID pandemic situation is worldwide, educators are facing a challenge to provide online education. Though there are lots of TMS (Teaching management Systems) available in the market, either they are costly or complicated to deploy and manage. Moodle is here to get rid of all of the challenges. How to install Moodle with Ubuntu 20.04 LTS.


  • Interactive GUI

The interface is very attractive, responsive, and easy to use for both mobile and desktop users.

  • Personalized Dashboard.

Here, you can navigate, current, and old curriculums.

  • Progress reports.

You can keep track of the curriculum, based on the course and student level.

  • File management.
- Advertisement -

A very convenient interface connected with Onedrive,  Dropbox, or any other famous cloud storage service.

  • Calendar and Notifications

A teacher can keep track of course deadlines, scheduled programs.  Forum and personalized messages can be shared.


Here, we will see how to set moodle with Ubuntu 20.04.

Update OS

$ sudo apt-get update

Install PHP/MySql/PHP

Here, we would require PHP7, add the repo.

$  sudo add-apt-repository ppa:ondrej/php

Update System

$ sudo apt-get update

Get required packages.

  $ apt install apache2 mysql-client mysql-server php libapache2-mod-php

Setup root password

$ sudo mysql_secure_installation

Install other required tools.

$ 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

Install git

$ sudo apt-get install git

Download Moodle package, change to /opt directory.

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

Move local repo to /var/www/html

Create new directory ‘moodledata’ in /var/

$ sudo mv /opt/moodle /var/www/html/moodle
$ sudo mkdir /var/moodledata 

Define required set of permissions.

$ sudo chown -R www-data /var/moodledata/
$ sudo chmod -R 755 /var/moodledata/
$ sudo chown www-data /var/moodledata
$ chmod -R 775 /var/www/html/moodledata

Moodle database user for MySQL required.

create user 'moodleuser'@'localhost' IDENTIFIED BY 'P@ssw0rd';
GRANT ALL ON moodle.* TO 'moodleuser'@'localhost';

Once all of the settings are done, restart apache service.

Open browser and type IP_Addr/moodle. In my scenario IP address is

Click next, change directory to /var/moodledata

Choose default Database type, provide credentials.

Database name: localhost

Database user: moodleuser

Database Password: P@ssw0rd

Copy all content to /var/www/html/moodle/config.php, you require to create that file.

$ vim /var/www/html/moodle/config.php
<?php  // Moodle configuration file
 global $CFG;
 $CFG = new stdClass();
 $CFG->dbtype    = 'mysqli';
 $CFG->dblibrary = 'native';
 $CFG->dbhost    = 'localhost';
 $CFG->dbname    = 'moodle';
 $CFG->dbuser    = 'moodleuser';
 $CFG->dbpass    = 'P@ssw0rd';
 $CFG->prefix    = 'mdl_';
 $CFG->dboptions = array (
   'dbpersist' => 0,
   'dbport' => '',
   'dbsocket' => '',
   'dbcollation' => 'utf8mb4_0900_ai_ci',
 $CFG->wwwroot   = '';
 $CFG->dataroot  = '/var/moodledata';
 $CFG->admin     = 'admin';
 $CFG->directorypermissions = 0777;
 require_once(DIR . '/lib/setup.php');
 // There is no php closing tag in this file,
 // it is intentional because it prevents trailing whitespace problems!

Accept conditions and move next.

Here, Moodle will go through, whether all required application are installed proper or not.

Get installation steps complete.

Assign credentials to admin, assign email id.

Move to next screen.

Save all changes and move next.

Save changes and finish setup, congratulations!! you have working Moodle EMS system ready to use.


Here, the config.php file may not be available as default. Make sure to create and save that file. Sometimes web server may show errors, restart server and apache service to get rid of this.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"


Please enter your comment!
Please enter your name here

Latest article