In this tutorial, you will learn how to install the MOODLE LMS 4.0 E-LEARNING PLATFORM on Linux Ubuntu 20.04 LTS in the cloud on the Amazon Web Services (AWS) cloud computing platform. Moodle is a free and open-source learning management system written in PHP and distributed under the GNU General Public License. Moodle is used for blended learning, distance education, flipped classrooms, and other online learning schemes in schools, universities, workplaces, and more! Moodle is provided freely as Open Source software, under the GNU General Public License. Anyone can adapt, extend or modify Moodle for both commercial and non-commercial projects without any licensing fees and benefit from the cost-efficiencies, flexibility, and other advantages of using Moodle. 

Moodle is also an easy-to-use system that comes with a simple interface, drag-and-drop features, and well-documented resources along with ongoing usability improvements making Moodle easy to learn and use. The Moodle project is well-supported by an active international community, a team of dedicated full-time developers, and a network of certified Moodle Partners. Driven by open collaboration and great community support, the project continues to achieve rapid bug fixes and improvements, with major new releases every six months. Continue watching this video to learn how to deploy your own cloud-hosted MOODLE version 4 Learning Management System (LMS) in just about 20 minutes!


The following is a list of items that you will need to complete this tutorial successfully:
1) An SSH client such as Putty or the Terminal app for macOS
2) A web browser such as Google Chrome, Firefox or Internet Explorer, or Safari
3) An Amazon Web Services account or IAM user account
4) A Linux Ubuntu 20.04 LTS instance hosted on Amazon Lightsail. (You can use any other VPS hosting service)
5) The LOMP stack and Moodle LMS installation files for Ubuntu Server.


The following is an overview of the steps outlined in this tutorial:
1) Connect to the Ubuntu Server via SSH and update the system repository. Set a hostname and point a domain name to the server
2) Download and install the LAMP stack
3) Download Moodle LMS and create a MySQL database
4) Open Moodle and complete the web-based post-installation setup
5) Configure a Lets Encrypt SSL certificate.

Step 1: Connect to the Ubuntu Server via SSH and update the system repository. Set a hostname and point a domain name to the server

Start the Moodle deployment process by creating a Linux Ubuntu 20.04 LTS instance. Sign in to your Amazon Web Services account, and use the search box at the top of the page to search for ‘Lightsail’. Click on the returned Lightsail search result to open the dashboard. Click the Create Instance button to open the instance creation wizard. On the ‘Select a platform’ section, choose Linux / Unix and on the ‘Select a blueprint’ section choose the Ubuntu 20.04 LTS blueprint. 

Scroll download to the ‘Choose your instance plan’ section and select the $10 plan which gives you ‘first three months free’. On the ‘Identify your instance’ section enter a name for the instance and click the Create Instance button.

Copy the public IP address for the instance and open the Amazon Route53 service. Click on Hosted Zones and click any hosted zone for your registered domain name. Click Create Record and set the record name to moodle-server. Paste in the IP address for this instance on the value field and click Create Record.

NB: We recommend configuring a static IP address on the instance. Click Here to learn how to set up a static IP.

Return back to the Lightsail dashboard and click on the Linux Ubuntu instance. Click the Connect tab and click Download default key. Open your terminal app and run the following commands to connect to the instance and update the system repository:
Once the update process completes, run the following command to set a hostname:

add the following configuration to the hosts file: moodle-server

To save the changes, press CNTRL + O, press ENTER, and press CNTRL + X to exit the file. Run the command below to edit the /etc/cloud/cloud/cloud.cfg configuration file.

Set Preserve_hostname: True, then press CNTRL + 0, press ENTER and press CNTRL + X to exit the file.

Step 2: Download and install the LAMP stack

The next step is to download the LAMP stack. LAMP stands for Apache, MariaDB, and PHP. It is a set of software packages that can run almost any web-based application or website. Run the commands below to install the LAMP stack

Run the command below to start the mysql_secure_installation script.

The script will ask a series of questions for making the MySQL installation more secure. Below are question and responses that you can provide:

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!

Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y.
Reload privilege tables now? [Y/n] Y.

Moodle is written in PHP and you need to ensure that you install it on your server. Install PHP and all needed extensions by running the commands:

Restart the apache web server for the changes to take effect

Step 3: Download Moodle LMS and create a MySQL database

To simplify the download process and to ensure that all files for the Moodle Learning Management system are downloaded the right way, use git to clone the Moodle LMS project to the /opt directory:

Copy the /opt/moodle directory to the /var/www/html directory
Set the necessary permissions on the moodle directory and ensure to specify the -R (recursive) option that ensures that all files within the moodle directory also get the same permission configuration:
Create a moodledata directory in the var/ directory and set the owner of the moodledata directory to the www-data user
To store all user-generated data and system settings, Moodle LMS needs a database. Run the commands below to create a MySQL database for the LMS

Step 3: Open Moodle and complete the web-based post-installation setup

You have downloaded the LAMP stack, download Moodle LMS using git, and created a MySQL database for the LMS. The next step is to open a new browser window and navigate to the domain name or server IP address for the Moodle LMS server. Ensure to append /moodle at the end of the URL i.e https://moodle-server-ip/moodle. On the Installation page, select a language and click Next

On the Confirm Paths page, change the Data Directory to /var/moodle and click Next

On the Choose Database Driver page, select MariaDB (native/mariadb) and click Next. On the Database Settings page, enter the Database name, username, and password then click Next. 

A Copyright Notice page will be shown. Read the Moodle copyright if you wish to and click Continue to accept the terms.

The Moodle LMS installer will run some checks to ensure that your server is configured correctly. Any issues with the setup will be indicated on this page. To make corrections simply navigate back to previous sections. However if there are no issues indicated on this page, click the Continue button to proceed to the next step,

A new page will be shown indicating the Moodle LMS installation progress. When the installation is complete you will see a page that will show a success status for each module of the LMS. Click the continue button and configure a username and password that you will use to administer the LMS. 

On the New Settings – Site home settings page, enter the name for the Site, a short name for the site and a site home summary. Scroll down and click the Save Changes button. The Moodle LMS dashboard will be shown thereafter.

Step 4: Configure a Let's Encrypt SSL Certificate.