Moodle is the world’s most popular learning management system. Moodle is Open Source and of course it’s compatible with the most popular Open Source Database : MySQL !
I’ve already posted an article on how to install Moodle on OCI before we released MySQL Database Service. In this article we will see how to deploy Moodle very easily in OCI and using MDS.
Once again we will use the easiest way to deploy an complete architecture on OCI: Resource Manager.
We will then use a stack I’ve created that is available on GitHub This stack includes Terraform code allowing to deploy different architectures that we can use for Moodle. I’ve tried to cover the main possible architecture directly in the stack. It’s also possible to just download the Terraform code and modify it if you need. You also have the possibility to generate again a stack from your modified code.
I’ve already multiple stacks you can deploy directly on OCI that allows you to deploy the same architectures as I cover in this article but for other solutions directly from this page: Deploy to OCI.
Let’s have a look at some of the possible architectures we can deploy directly by clicking on the “deploy to OCI” button.
Simplest Deployment
This deployment, is the most simple to deploy. One single MySQL Database Service Instance and one compute instance as the Moodle Web Server.
The architecture is composed by the following components:
- Availability domains: Availability domains are standalone, independent data centers within a region. The physical resources in each availability domain are isolated from the resources in the other availability domains, which provides fault tolerance. Availability domains don’t share infrastructure such as power or cooling, or the internal availability domain network. So, a failure at one availability domain is unlikely to affect the other availability domains in the region.
- Virtual cloud network (VCN) and subnets: a VCN is a customizable, software-defined network that you set up in an Oracle Cloud Infrastructure region. Like traditional data center networks, VCNs give you complete control over your network environment. A VCN can have multiple non-overlapping CIDR blocks that you can change after you create the VCN. You can segment a VCN into subnets, which can be scoped to a region or to an availability domain. Each subnet consists of a contiguous range of addresses that don’t overlap with the other subnets in the VCN. You can change the size of a subnet after creation. A subnet can be public or private.
- Internet gateway: the internet gateway allows traffic between the public subnets in a VCN and the public internet.
- Network security group (NSG): NSGs act as virtual firewalls for your cloud resources. With the zero-trust security model of Oracle Cloud Infrastructure, all traffic is denied, and you can control the network traffic inside a VCN. An NSG consists of a set of ingress and egress security rules that apply to only a specified set of VNICs in a single VCN.
- MySQL Database Service (MDS): MySQL Database Service is a fully managed Oracle Cloud Infrastructure (OCI) database service that lets developers quickly develop and deploy secure, cloud native applications. Optimized for and exclusively available in OCI, MySQL Database Service is 100% built, managed, and supported by the OCI and MySQL engineering teams.
- Compute Instance: OCI Compute service enables you provision and manage compute hosts in the cloud. You can launch compute instances with shapes that meet your resource requirements (CPU, memory, network bandwidth, and storage). After creating a compute instance, you can access it securely, restart it, attach and detach volumes, and terminate it when you don’t need it. Apache, PHP and Moodle are installed on the compute instance.
Let’s see the different steps to deploy this architecture directly from here:
You will redirected the OCI’s dashboard create stack page:
As soon as you accept the Oracle Terms of Use, the form will be pre-filled by some default values.
You can of course decide in which compartment you want to deploy the architecture:
The second screen of the wizard the most important form where we need to fill all the required variables and also change the architecture as we will see later:
The second part of the form looks like this. Note that we can enable High Availability for MDS, use multiple Web Server Instances or use existing infrastructure. This means that we have the possibility to use an existing VCN, subnets, etc…
And of course we can also specify the Shapes for the compute instances (from a dropdown list of the available shapes in your tenancy and compartment) and for the MDS instance (this one needs to be entered manually).
When we click next, we reach the last screen which summarize the choices and we can click on “Create”. By default the Architecture will be automatically applied (meaning all necessary resources will be deployed):
Now we need to be a little bit of patience while everything is deployed…
Other Possible Architectures
As we could see earlier on the second screen of the stack’s creation wizard, we could also specify the use of multiple Web Servers. Then we have the possibility to deploy them on different Fault Domains (default) or use different Availability Domains:
It’s possible to also specify if all Moodle servers will use their own database and user or share the same schema in case we want to use a load balancer in front of all the web servers and spread the load for the same site/application.
The default architecture with 3 web servers looks like this:
And if you want to enable High Availability for the MDS instance, you just need to check the box:
And you will have an architecture like this:
Finishing Moodle’s Installation
When the deployment using the stack is finished, you will the a nice large green square with “SUCCEEDED” and in the log you will also see some important information:
This information is also available in the Output section on the left:
Now, we just need to open a web browser and enter that public ip to finish the installation of Moodle:
And we follow the wizard until the database configuration section:
On the screen above, we use the information that we can find in the Stack’s output section.
Then we continue the installation process until it’s completed and finally we can enjoy our new Moodle deployment:
As you can see, it has never been so easy to deploy applications using MySQL in Oracle Cloud Infrastructure.
[…] Yesterday, we saw how to easily deploy Moodle to OCI with MDS. […]
Hi Lefred,
Than you for sharing. I just created the stack with the Apply job and I’d like to know how to access the web moodle console. I’m trying typing:
http://
and
http:///moodle
in the browser, but I have no answer. Which is the right way?
Thank you so much.
you need to pass the public IP of your compute instance
Hello Lefred,
Many thx for your detailed tutorial, it is very helpful. I am looking to deploy moodle on Oracle Kubernetes with MYSQL, wondering if you could help us.
Regards,
Pooja
Hi Pooja,
My K8s experience is limited, but I think you should take a look at https://github.com/mysql/mysql-operator
Hi Lefred,
Many thanks for your kind response,
I am using Oracle SQL as DB, If I use your packages of Moodle I do not get any error, however, when I am using https://hub.kubeapps.com/charts/bitnami/moodle/7.0.4 I am getting error that:
SET GLOBAL innodb_file_format = barracuda;
SET GLOBAL innodb_file_per_table = 1;
SET GLOBAL innodb_large_prefix = ‘on’;
regardless of the installation method of installing on OCI or Kubernetes both are using the same packages, however, I do not get errors with your method.
Maybe, I reframe my question, In your method, have you modify anything which does not give the above errors?
Also, in your “multiple Web Servers” can we create multiple behind Oracle Load Balancer and user Oracle File Storage to install moodle on the common folder which also gives high availability
Regards,
Pooja
If you are using Oracle DB, those settings are not needed as they are for MySQL. Also those settings are obsolete in recent version of MySQL. You should not deal with that.
About your other questions, everything is possible, but you will have to setup that by yourself.
Cheers,
Hi,
when I tried to deploy the moodle, I get the below error:
Initializing modules…
– mds-instance in modules/mds-instance
– moodle in modules/moodle
There are some problems with the configuration, described below.
The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.
Error: Unsupported block type
on modules/moodle/variables.tf line 112:
112: dynamic “shape_config” {
Blocks of type “dynamic” are not expected here.
Please let me know what I am missing here
it was a wrong replacement doing the upgrade of the module to 8.0.26, you can git pull or simply remove the block
thank you for pointing it
Pardon for my noob comment, but I don’t know how to remove the block. Can you please help? I tried to git pull but saw there is no other branch. Can you please update the git or terraform file? so that I can deploy now.
thanks
Just do git pull, or if you use OCI stack, download the zip again
new error for you sir:
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running “terraform plan” to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Error: Reference to undeclared local value
on modules/moodle/main.tf line 54, in resource “oci_core_instance” “Moodle”
54: for_each = local.is_flexible_node_shape ? [1] : []
A local value with the name “is_flexible_node_shape” has not been declared.
Will need to check later 😉
You can try again 😉
Hi Lefred,
It is our first time to deploy Moodle on OCI. We created a Moodle instance and a MySQL database service. Upon checking, the deployment was pretty much straightforward — it’s automatic installation. Our question is, is there a way to deploy Moodle on existing instance and MySQL database?
Hi,
Sure you need to provide the OCID’s of the compute and MDS instances. However, I don’t recall if I provide such option in the stack. But this is feasible of course in Terraform module provided.
Hi, Is this compatible with Canonical Ubuntu or any OS besides OEL? Thank you!
No these modules are only for OL (I use rpms) but you can modify them at your convenience
Thanks @lefred, very interesting and helpful.
In the HA option for the Web servers; does it recommended to use Load Balancer in front of them?
what do you think about using instance pool for the Web servers?
appreciate your thoughts.
Hello, if you plan to use multiple webservers of course a load balancer in front of them is a right choice.
Cheers,
How can you connect to SSH?
I have deployed the stack twice. But for some reason, I am getting the trailing error:
“Error: Database connection failed
It is possible that the database is overloaded or otherwise not running properly.
The site administrator should also check that the database details have been correctly specified in config.php
Warning: mysqli::__construct(): (HY000/1045): Access denied for user ‘moodle’@’10.0.0.219’ (using password: YES) in /var/www/html/lib/dml/mysqli_native_moodle_database.php on line 83
“
Hello Sanil,
did you use the stack to deploy to OCI ?
Check if there were some errors during the deployment.
I know there were some changes recently, I will verify if all it working as expected.
I’ve updated the code of the stack. Now it deploys OL9 and you can use Ampere shape.