AWS Documentation

  1. Home
  2. Docs
  3. AWS Documentation
  4. AWS Moodle 4.1+ AMI on Amazon Linux 2

AWS Moodle 4.1+ AMI on Amazon Linux 2

This AMI is a LAMP Web Server with phpMyAdmin installed on Amazon Linux 2.

This AMI supports following versions.

  • PHP 8.0
  • Apache 2.4
  • MariaDB 10.5
  • phpMyAdmin 5.2
  • Moodle 4.1+

Web Server

We prepared SSL/TLS so you can access to top page using http:// or https://.

Moodle Installation

Once the instance is running, please access your Moodle hosting domain or enter the public DNS provided by AWS (IPv4 Public IP) into your browser.
https://<Moodle host name or IP>/

Choose a language

click Next

Confirm paths

  • Web address: URL
  • Moodle directory: /var/www/html/moodle
  • Data directory: /var/www/html/moodledata

click Next

Choose database driver

Type: MariaDB

click Next

Database settings

  • Database host: localhost
  • Database name: moodle
  • Database user: moodle
  • Database password: Check Application Password
  • Tables prefix: mdl_

click Next

Application Password

You can find the password from EC2 management console System Log.

  1. Go to Amazon EC2 console at
  2. Chose your Instance and Click Actions → Instance Settings → Get System log

Get System log

You can also SSH into your instance and find the login credential using the following command.

$ cat /home/ec2-user/credentials 
////////////////////credentials info////////////////////
--- moodle
----- Setting  : Success
--- phpMyAdmin
----- Setting  : Success
----- User     : root
----- Password : gfm6Wr2ifJdbiueh
--- MariaDB
----- User     : moodle
----- DB name  : moodle
----- Password : tgu6gHlcBkpt6plz

Copyright notice

click Continue

Server checks

click Continue


scroll down the page

click Continue


On this page you should configure your main administrator account which will have complete control over the site. Make sure you give it a secure username and password as well as a valid email address. You can create more admin accounts later on.

Please fill out the required information.

  • Username:
  • New password:
  • First name:
  • Surname:
  • Email address:

click Update profile

New settings

Please fill out all information.

click Save changes

Complete your site registration

We’d love to stay in touch and provide you with important things for your Moodle site! By registering:

  • Privacy notice and data processing agreement: Check

click Register your site

click Continue



Change URL

If the website IP Address is changed due to a stop or start instance, the website is not accessible with the new IP Address. In this case, you will need to replace the old URL with the new URL to gain access.

Update config.php with the URL of the new server

$ sudo vi /var/www/html/moodle/config.php

// old
$CFG->wwwroot   = '';
// new
$CFG->wwwroot   = '';

Update links containing wwwroot in the database

cd /var/www/html/moodle
php admin/tool/replace/cli/replace.php --search=//oldsitehost --replace=//newsitehost


$ sudo -u apache php admin/tool/replace/cli/replace.php --search=// --replace=//
Several tables are not updated as part of the text replacement. These include configuration, log, events, and session tables.

This script should be considered experimental. Changes made cannot be reverted, thus a complete backup should be made before running the script!

type y (means yes) or n (means no)
: y
UPDATE mdl_adminpresets
                       SET name = REPLACE(name, ?, ?)
                     WHERE name LIKE ? COLLATE utf8mb4_bin ESCAPE 
[array (
0 =&gt; '//',
1 =&gt; '//',
2 =&gt; '%//',
Query took: 0.00036787986755371 seconds.
UPDATE mdl_workshopform_rubric_levels
                       SET definition = REPLACE(definition, ?, ?)
                     WHERE definition LIKE ? COLLATE utf8mb4_bin ESCAPE '\\'
[array (
  0 => '//',
  1 => '//',
  2 => '%//',
Query took: 0.0004119873046875 seconds.
++ Replacing in html blocks... ++
++ ...finished ++
== Success ==

If you see this message.

The replacement is longer than the original and shortening is not allowed; cannot continue.

use --shorten option.


$ sudo -u apache php admin/tool/replace/cli/replace.php --search= --replace= --shorten


You can access phpMyAdmin after creating ssh tunnel. Please refer to AWS LAMP with PHP 8.1 on Amazon Linux 2


Was this article helpful to you? Yes No

How can we help?