Moodle is a free and open-source learning management system written in PHP and released under the GNU General Public License. You can create learning courses from Moodle and share them with your viewers/friends/students e.t.c.

Moodle Dependencies

Moodle has the following dependencies

  • PHP
  • Apache / Nginx Web server
  • MySQL / MariaDB database server

In this tutorial, we will install and configure Moodle to use MariaDB database and Apache web server.

Step 1: Install PHP

PHP is available on both Debian and Ubuntu repositories. Install it by running the following commands

sudo apt -y install vim php-cli  php-intl php-xmlrpc php-soap php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath

Step 2: Install MariaDB Database Server

After installing PHP, next is to setup MariaDB database server using our guides below:

How to Install MariaDB 10.3 on Debian 9 / Debian 8

Install MariaDB 10.3 on Ubuntu 18.04 and CentOS 7

Once the database server is installed, open the configuration file

sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf

Then add below lines under  [mysqld] section

innodb_file_format = Barracuda 
default_storage_engine = innodb
innodb_large_prefix = 1
innodb_file_per_table = 1

Save the changes and restart mysql service.

sudo systemctl restart mysql

Login to the mysql console as root user to create database and user.

$ mysql -u root -p

Create a database and user for Moodle

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL ON  moodle.* TO 'moodle'@'localhost' IDENTIFIED BY "StrongPassword";

Step 3: Download and Configure Moodle

Download the latest release of Moodle from Github

sudo apt -y  install wget

Extract the downloaded file

tar xvf moodle-latest-35.tgz

Move the created directory to /srv directory

sudo mv moodle /srv/

Create an empty directory to hold Moodle files.

sudo mkdir /srv/moodledata

Set permissions for Moodle web directory

sudo chown -R www-data:www-data /srv/moodle/ /srv/moodledata

Step 4: Install  & Configure Apache Web Server

We also need Apache web server to host our Moodle application. Install it like below:

sudo apt -y install apache2 vim libapache2-mod-php

Create an Apache VirtualHost configuration file

sudo vim /etc/apache2/sites-enabled/moodle.conf

Put the contents below into the file

<VirtualHost *:80>
     DocumentRoot /srv/moodle/
     ServerAdmin [email protected]
     <Directory /srv/moodle/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted

     ErrorLog /var/log/apache2/moodle-error.log
     CustomLog /var/log/apache2/moodle-access.log combined

Replace with your domain name, save the file and exit.

Enable the Apache rewrite module

sudo a2enmod rewrite
sudo systemctl restart apache2

Step 5: Access Moodle Setup Wizard

Now browse to your Moodle server IP or Hostname to finish the setup of Moodle on Ubuntu 18.04 / Debian 9.

1. Choose your installation language for Moodle and click “Next”

install moodle ubuntu 18.04 debian 9 01

2. Setup Web address, Moodle directory, and Data directory

install moodle ubuntu 18.04 debian 9 02

3. On the next page, choose a database driver – Mariadb (native/mariadb)

install moodle ubuntu 18.04 debian 9 03

4. Provide Database host, Database name, Database user and Database password

install moodle ubuntu 18.04 debian 9 04

5. Confirm that you have read the conditions and understood them

install moodle ubuntu 18.04 debian 9 05

6. If your server environment meets all minimum requirements, click Continue to finish the installation.

install moodle ubuntu 18.04 debian 9 06

7. Create an admin user account on the next page

install moodle ubuntu 18.04 debian 9 07

8. Configure your Front page settings

install moodle ubuntu 18.04 debian 9 08

10. You should now get to Moodle dashboard.

install moodle ubuntu 18.04 debian 9 09

Congratulation!!. You just installed Moodle E-Learning platform on Ubuntu 18.04 / Debian 9. Enjoy and stay connected for more nice how-to guides.


Please enter your comment!
Please enter your name here