How to install Moodle on Ubuntu 16.04

Hello again, in this article you will be able to learn another experience i got in my career. As a person who loves to do more experiments, I just bought two servers (Linode and Digital Ocean) with different level Resources.

Install and Configure Apache and Services

Install PHP 7.2 (Minimum Version for Moodle 3.9.1+)

apt-get install php7.2 php7.2-curl php7.2-gd php7.2-intl php7.2-ldap php7.2-mysql php7.2-pspell php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-common php7.2-opcache php7.2-mbstring php7.2-soap

after Installing Apache, we have to start and enable the service with following commands.

apt-get install apache2

After installing apache2

With the following code, you can be able to set the correct root for the moodle installation.

nano /etc/apache2/sites-available/000-default.conf

Just replace the following line

DocumentRoot "/var/www/html/moodle/"

Then restart the Apache service.

systemctl restart apache2

Install and configure MariaDB

Run the following command to install mariadb server. (If you didn;t get the latest version, please check our previous article, it has the way to update maradb version to latest)

apt-get install mariadb-server

Restart the MySQL service

systemctl start mysql

systemctl enable mysql


Configure MariaDB.

In order to get your MariaDB to be compatible with Moodle, you need to enable “InnoDB” engine.

Open the following file with Nano or any text editor.

nano /etc/mysql/mariadb.cnf

Then, add the following code to the end of the file

default-character-set = utf8mb4

innodb_file_format = Barracuda
innodb_file_per_table = 1

character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

default-character-set = utf8mb4

Then save and exit

systemctl restart mysql

Create Database and User for Moodle

mysql -u root -p

create database moodle;

grant all privileges on moodle.* to 'admin'@'localhost' identified by 'password';


Download and Install Moodle 3.9.1+

Download the Latest Stable Version


Execute the following command to extract moodle

tar xvzf moodle-latest-34.tgz -C /var/www/html/

Set Apache as the owner of the whole DocumentRoot:

chown -R www-data:www-data /var/www/