Install Moodle on Ubuntu Server

Moodle is an open source course management system written in PHP and allows you to create online training material to facilitate distance learning. Many educational institutions are hosting Moodle to deliver distance learning as it’s free under the GNU general public license.

In this Tutorial I will show you how to install and configure Moodle onto Ubuntu server. I will assume that you already have Ubuntu server running.

Install Apache/MySQL/PHP

Like any web based application, Moodle needs a web server, database server and PHP modules to run so in this instance you will install Apache, MySQL and PHP in one go by using the following command:

sudo apt install apache2 mysql-client mysql-server php libapache2-mod-php

Once this software has been installed you can help secure the Apache server by disabling directory listing with:

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf

In addition, you should secure the MySQL server by setting the root password with:

sudo mysql_secure_installation

Don’t forget to keep a not of the password as it will be required later in this tutorial. Finally install the additional software that will be required :

sudo apt install graphviz aspell ghostscript clamav php7.2-pspell php7.2-curl php7.2-gd php7.2-intl php7.2-mysql php7.2-xml php7.2-xmlrpc php7.2-ldap php7.2-zip php7.2-soap php7.2-mbstring

At this point you should restart Apache to ensure that the modules have been installed correctly. The table below lists the commands that can be used for starting, stopping Apache server etc.

Start Apachesudo systemctl start apache2.service
Stop Apachesudo systemctl stop apache2.service
Start Apache after Server Rebootsudo systemctl enable apache2.service
Restart Apache Serversudo service apache2 restart

In this instance you should restart Apache with:

sudo service apache2 restart

And enable Apache to start after a server reboot with:

sudo systemctl enable apache2.service

You can now check to see if Apache is running properly by entering the local IP address of your server into your browser. If all goes well you should see the following the Apache default page