How to install Moodle on Ubuntu 16.04?

Moodle is a free and open-source learning management system written in PHP. Moodle is used for blended learning, distance education, flipped classroom and other e-learning projects in schools, universities, workplaces and other sectors. it is used to create private websites with online courses for educators and trainers to achieve learning goals. Plugins are a flexible toolset, allowing Moodle users to extend the features of the site.Moodle runs without modification on Unix, Linux, FreeBSD, Windows, OS X, NetWare and any other systems that support PHP.

Install PHP 7.0

You can easily install PHP 7 and the needed dependencies with the command below:

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

Install Apache

Obviously, in order to serve our Moodle, we need a web server. we are going to install Apache as our web server:

apt-get install apache2

After the installation process is finished, you have to start and enable the Apache service with following commands:

systemctl enable apache2
systemctl start apache2

for setting the correct DocumentRoot, open your Apache configuration file with the command below:

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

Find the line that refers to “DocumentRoot” and change it like below:

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

Then restart Apache service to take effect:

systemctl restart apache2

Install and configure MariaDB

Execute the following command to install MariaDB and its service:

apt-get install mariadb-server

Start and enable the 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 MariaDB configuration file with your text editor:

nano /etc/mysql/mariadb.cnf

Add the following lines at the very 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.

Restart MariaDB service to take effect:

systemctl restart mysql

Create Database and User for Moodle

In this section, we are going to create a Database for Moodle and a user who have the privileges.

Log in to your MariaDB as root user with the following command:

mysql -u root -p

Issue the following command to create a database (replace the red parts with your own values):

create database moodle;

Create a user with full privileges on Moodle database:

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

It’s done, you can log out with the following command:


Download and install Moodle

You can download the latest stable version of Moodle with the following command:


Execute the following command to extract the files to the correct path:

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/

Installing Moodle

Now you have to open your browser and enter your Domain or your Public IP Address, you should see a page like below:

Was this answer helpful? 0 Users Found This Useful (0 Votes)