Moodle Installation Guide for Ubuntu Linux (1)

Vijay Yongjoon Park
7 min readJan 16, 2018

--

by Yongjoon Park, S2HSP/GIZ Nepal

Overview

Moodle (Modular Object-Oriented Dynamic Learning Environment) is a free and open-source learning management system. Developed on pedagogical principles, Moodle is used for blended learning, distance education, flipped classroom and other e-learning projects in schools, universities, workplaces and other sectors. With customizable management features, it is used to create private websites with online courses for educators and trainers to achieve learning goals. Moodle allows for extending and tailoring learning environments using community sourced plugins. (https://en.wikipedia.org/wiki/Moodle)

Paying attention to its usability and flexibility, the Health Information System (HIS) team of GIZ Nepal has been utilising Moodle as a comprehensive platform for electronic reporting (e-reporting) training for health facilities in Nepal. This e-reporting training at the facility level is in progress as part of the implementation process of a new electronic Health Management Information System (HMIS), and Moodle as a training platform has been quite useful and proven efficient for both teaching and learning.

For example, HIS team register trainees, conduct surveys, share materials, carry out tests and grade trainees, and so on during each training event. All these activities are done on screen by trainees with laptops, and training data are safely stored electronically. Trainees can have easier access to different learning activities and related materials. Furthermore, they can learn basic concept and practice using web-based software, and it helps them familiarize with HMIS as well.

This guide describes how to install Moodle 3.4 on Ubuntu 16.04 LTS. It also covers version upgrade and simple database migration to another server. We focus on easy and quick installation for less complicated application. More detailed installation process can be found in the official documentation.

A local instance of Moodle in your computer could work as a server for a class of dozens of people. We use local server environment for the e-reporting training considering poor internet connection at some training venues in Nepal. However, there are a few of options if you want to run it online through a web hosting service. (e.g. Moodle Cloud)

Procedure

  1. Installation of Moodle 3.4 on Ubuntu 16.04 LTS
  2. Upgrade of Moodle to Higher Version
  3. Full Migration from One Server to Another

PART 1. INSTALLATION OF MOODLE 3.4 ON UBUNTU 16.04 LTS

Step 1. Preparation

  • Prepare a computer with Ubuntu 16.04 LTS.
  • Open Terminal. Update and upgrade APT packages.
$ sudo apt update
$ sudo apt upgrade

Step 2. Download Moodle

  • Download the official update of Moodle from its website.
  • Extract Moodle in a preferred location. (e.g. Documents)

Step 3. Set up LAMP

  • ‘LAMP’ is a popular combination of open source software (Linux/Apache/MySQL/PHP) to set up a server for dynamic web sites and web applications. It is also recommended for Moodle.
  • Install necessary LAMP components. Run this command to install Apache web server.
$ sudo apt install apache2
  • You can start the web server by
$ sudo service apache2 start

(But it is mostly likely already working upon installation.)

  • Type ‘localhost’ in your browser to see Apache is properly working.
  • Install MySQL.
$ sudo apt install mysql-client mysql-server
  • MySQL will ask you to set up a root password during the process.
  • You can start MySQL server by
$ sudo service mysql start
  • Install PHP (server-side scripting language).
$ sudo apt install php7.0 libapache2-mod-php7.0

Step 4. Install Additional Software

  • Install other additional software using APT commands.
$ sudo apt install graphviz aspell ghostscript clamav php7.0-pspell php7.0-curl php7.0-gd php7.0-intl php7.0-mysql php7.0-xml php7.0-xmlrpc php7.0-ldap php7.0-zip php7.0-soap php7.0-mbstring
  • Please consult the official documentation for the list of software. It might be different depending on which version of Moodle you are installing.

Step 5. Run Apache Web Server

  • Restart Apache so that the modules are loaded correctly.
$ sudo service apache2 restart

Step 6. Move Moodle to /var/www/html/

  • In this step, you will copy the extracted Moodle folder from Step 2 to the default root folder of Apache.
  • Sort out permission issues of the root folder of Apache. If you copy the folder into the root folder, you will get ‘Permission denied’. It is because the folder is only accessible by the Linux root user.
  • To make the installation easier, you can temporarily give yourself (the current user) full access to the folder. (Of course, you have to turn it back later for security reasons.)
$ sudo chmod -R 777 /var/www/html/

✓ chmod: ‘change mode’, Unix/Linux command to change access permissions.
✓ -R: recursively
✓ 777: Permissions to read (4), write (2) and execute (1) for owner, group and others.

  • Copy and paste Moodle folder in /var/www/html/
  • Then we also need to change access permission of Moodle folder so that Apache can write files for installation.
$ sudo chmod -R 777 /var/www/html/moodle/

Step 7. Create ‘moodledata’ Folder

  • Create a data repository for Moodle. Here we put it in /var/
$ sudo mkdir /var/moodledata
  • Since /var/ is a subdirectory of the root directory in Linux, you must use sudo command to make a change.
  • Give 777 mode to this folder since the web server should have access to it in order to write data.
$ sudo chmod -R 777 /var/moodledata

Step 8. Set up MySQL Database

  • You have MySQL that is already running. Now you need to create a Moodle database and a Moodle MySQL user with the correct permissions.
  • Please connect to the MySQL server. Use the password you created in Step 2.
$ mysql -u root –p
  • You are in MySQL.
  • Create a MySQL database for Moodle. We use ‘moodle’ as a database name.
> CREATE DATABASE [dbname] DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
  • Then, create a MySQL user for your Moodle database by specifying a username and password. We again use ‘moodle’ for both username and password.
> CREATE USER '[username]'@'localhost' IDENTIFIED BY '[password]';
  • Define privileges of the user to manage the ‘moodle’ database.
> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER ON moodle.* TO [username]@localhost IDENTIFIED BY '[password]';
  • Quit MySQL.
> quit; or exit;
  • You are now back in Bash shell.

Step 9. Proceed with Moodle Installer

  • Everything is ready for installation. Open your browser and go to
    http://[IP.ADDRESS.OF.SERVER]/moodle
  • Since it is a local environment, your server address would be just ‘localhost’.
  • It will be directed to the installer by install.php
  • Change the path for ‘moodledata’.
    /[your path]/moodledata
  • We set it like /var/moodledata
  • Choose database type.
    mysqli (Improved MySQL)
  • Configure database settings.
    Host server: localhost
    Database: moodle
    User: moodle (the user you created when setting up the database)
    Password: moodle (the password for the user you created)
    Tables Prefix: mdl_
  • Read and confirm the copyright notice.
  • Environment check is in progress. This will indicate if any elements required to run Moodle haven’t been installed.
  • Installation is underway. When it is done, please hit ‘Continue’.

Step 10. Complete Setup

  • Create a site administrator account which will have administrator permissions.
  • The password you select has to meet certain security requirements.
  • Name your Moodle site and finish other settings.
  • Installation complete.
    Congrats, you can now start using Moodle!

Step 11. Revert Permissions

  • Don’t Forget! If you made the webroot writable, revert permissions.
$ sudo chmod -R 755 /var/www/html/

✓ 755: Permissions to read (4), write (2) and execute (1) for owner, only read (4) and execute (1) for group and others.

--

--