LTS Installation Guide Moodle-3.9 Ubuntu-20.04

From MoodleDocs

General Info

This guide is going to be specific to Ubuntu/Moodle LTS versions. In self-hosted situations sticking with LTS releases for the OS and Moodle versions seems like the best bet for easier administration and stability. This Moodle-3.9 & Ubuntu-20.04 combination should work well for a few years and should only need to be revised minimally between new LTS releases of Ubuntu and Moodle.

Using LTS versions creates a moodle system that administrators will get familiar with managing over an extended period of time and teachers/students will get more familiar with over that time frame as well. This makes tweaking and optimizing over time easier for administrators as they become more familiar with the systems and as more faculty/staff/students become familiar with the system it's easier for them to help others. Spreading out the institutional knowledge.

OS - Ubuntu 20.04

Install & Update Ubuntu Server 20.04.

Pretty self explanatory. The only during-install addition being included is the SSH server for remote access.

Software Install

Install Apache/MySQL/PHP sudo apt install apache2 mysql-client mysql-server php libapache2-mod-php Additional Software Install. sudo apt install php7.4-mysql php7.4-xml php7.4-mbstring php7.4-curl php7.4-zip php7.4-gd php7.4-intl php7.4-xmlrpc php7.4-soap Restart Apache: sudo service apache2 restart

Get Moodle - Using GIT!

Git is a version-control system that makes updating easier. It seems to be installed on 20.04 by default, but just in case... sudo apt install git

Clone the Moodle GIT repository & track the branch you want to use. This example is putting the cloned repository in the /opt directory to provide some ability to fine-tune control over future GIT updates.

WARNING: Current example uses the MASTER branch. This is an unstable development code base! This should only remain here until MOODLE_39_STABLE branch is created cd /opt sudo git clone git://git.moodle.org/moodle.git cd moodle sudo git branch -a sudo git branch --track master origin/master sudo git checkout master

Copy the repository from /opt to the web server and create/modify folder permissions.

sudo cp -R /opt/moodle/ /var/www/html/ sudo mkdir /var/moodledata sudo chown -R www-data /var/moodledata sudo chmod -R 777 /var/moodledata sudo chmod -R 0755 /var/www/html/moodle

MySQL Server Setup

Hardening the MySQL install.

Keep track of the MySQL password this command will ask you to create. Losing this is a headache.

sudo mysql_secure_installation

  • Validate Password Component: Yes
  • Strong: 2
  • Password: <Pick Some Password>
  • Remove Anonymous Users: Yes
  • Disallow root login remotely: Yes
  • Remove test database: Yes
  • Reload privilege tables now: Yes

Access MySQL to create the moodle database & user sudo mysql -u root -p

At the 'mysql>' prompt.
Change the default character set. CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; Create a database user/password for the moodle installation to use. Modify 'moodledude' and 'passwordformoodledude' create user 'moodledude'@'localhost' IDENTIFIED BY 'passwordformoodledude'; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodledude@localhost; quit;

Web Installer

To use the web installer you need to allow write access to the moodle directory. This is hilariously not safe at all. Make sure you change the permissions back.

sudo chmod -R 777 /var/www/html/moodle

Navigate to the install IP: http://<hostip>/moodle

After going through the install, change permissions back: sudo chmod -R 0755 /var/www/html/moodle

The web installer is pretty self explanatory. You'll need the MySQL user/password from the MySQL setup step.