How to Install Moodle on Ubuntu 18.04

r00t July 26, 2018

Install Moodle on Ubuntu 18.04

In this tutorial we are going to learn how to install Moodle on Ubuntu 18.04. We will also install and configure its prerequisites. Moodle (acronym of Modular-object-oriented dynamic learning environment) is a free and open source learning management system built to provide teachers, students and administrators single personalized learning environment.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 18.04 LTS Bionic Beaver minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Moodle on Ubuntu 18.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y
apt-get upgrade -y
apt-get install git-core graphviz aspell -y

Step 2. Installing LAMP on Ubuntu 18.04 LTS.

You should check out this LAMP stack install tutorial for Ubuntu 18.04, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that Moodle relies on:

apt-get install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip

Step 3. Installing Moodle on Ubuntu 18.04 Bionic Beaver.

Next, you will need to download the latest stable version of the Moodle. You can download it with the following command:

wget https://download.moodle.org/download.php/stable35/moodle-latest-35.tgz
tar -zxvf moodle-latest-33.tgz
sudo mv moodle /var/www/html/moodle

Now just set the right permissions for the folders:

chown -R www-data:www-data /var/www/html/moodle/
chmod -R 755 /var/www/html/moodle/

Step 4. Create a database for Moodle.

Next, we need to create a database for the Moodle installation:

mysql -uroot -p

Run the following command to create a database for Moodle:

MariaDB> CREATE DATABASE moodle;
MariaDB> GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY 'PASSWORD';
MariaDB> FLUSH PRIVILEGES;
MariaDB> exit

Step 5. Configure Apache web server for Moodle.

For this you can take the default config as a template:

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/moodle.conf

Now edit the currently created Config as follows:

nano /etc/apache2/sites-available/moodle.conf

Modify the virtual host file for your Moodle site to resemble the example below:

<VirtualHost my-domain.tld:80>

ServerName my-domain.tld
ServerAlias www.my-domain.tld
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/moodle/

<Directory /var/www/html/moodle/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error-moodle.log
CustomLog ${APACHE_LOG_DIR}/access-moodle.log combined
</VirtualHost>

Now just activate the newly created Config, mod_rewrite and SSL:

sudo a2ensite moodle.conf && sudo a2enmod SSL && sudo a2enmod rewrite

Finally, reload the web server as suggested, for the changes to take effect:

systemctl restart apache2

Step 6. Accessing Moodle.

Now you can access the Moodle web install wizard in your browser by entering the domain name or http://your_ip/ to continue your Moodle installation.

Congratulation’s! You have successfully install and configured Moodle on your Ubuntu 18.04 server. Thanks for using this tutorial for installing Moodle open source learning system on Ubuntu 18.04 LTS (Bionic Beaver) system.

The Tags:

Leave a Comment

Comments are closed.