Article

Table of Contents
Try Vultr Today with

$50 Free on Us!

How to Install Moodle on Ubuntu Server 16.04

Published on: Mon, May 1, 2017 at 6:47 pm EST
Linux Guides Ubuntu Web Servers

Moodle is a popular, robust open-source learning platform to create personalized learning environments supported by a global community of people that powers learning environments worldwide. In this guide you will learn how to install and setup Moodle on your Ubuntu 16.04 server instance.

Prerequisites

  • A 1GB Ubuntu Server 16.04 server instance.
  • The typical LAMP stack (Apache, MySQL and PHP).

Preparation

Step 1

  1. Update the OS packages: apt-get update
  2. Install the required PHP modules: apt-get install aspell graphviz 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
  3. Restart the Apache web server: service apache2 restart

Step 2

Download Moodle via Curl from the official Moodle distribution server.

  1. Download the Moodle files: curl -L https://download.moodle.org/download.php/direct/stable32/moodle-latest-32.tgz > moodle.tgz
  2. Extract the Moodle files from the downloaded archive and place them in the default Apache document root: sudo tar -xvzf moodle.tgz -C /var/www/html

Step 3

We are now going to create a directory for Moodle outside the web root folder to store course related data. This is a more secure approach compared to storing the course data inside the Moodle root directory:

  1. Create the directory: mkdir /var/moodledata
  2. Change the ownership of the directory so the web server user has access to it: chown -R www-data /var/moodledata
  3. Set the proper permissions of the directory: chmod -R 0770 /var/moodledata

Step 4

Now we need to create the MySQL database that Moodle will use to store its data. We'll configure MySQL to follow the structure which Moodle expects. and create a user for the database.

Open up the MySQL config file.

nano /etc/mysql/mysql.conf.d/mysqld.cnf

Under the "Basic Settings" section, add the following lines.

default_storage_engine = innodb
innodb_file_per_table = 1
innodb_file_format = Barracuda

Save the config file and restart MySQL.

service mysql-server restart

Now we can create the database.

Login to MySQL.

mysql -u root -p

Enter the root password when prompted which you specified during the MySQL setup.

Step 5

Enter the following command to create the database.

CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Create the database user permissions for the database.

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO 'moodler'@'localhost' IDENTIFIED BY 'YourMoodlePassword';

Exit the MySQL CLI.

quit;

Note: You should use a secure password for your database.

Conclusion

Congratulations! You now have a successful installation of Moodle running on your Ubuntu Server 16.04 instance. To complete the installation, open your browser and navigate to http://YOUR_SERVER_IP/moodle. This should be very straightforward but you can always refer to the official installation guide.

Want to contribute ?

You could earn up to $300 by adding new articles