Skip to content

Linux VPS & VPS Windows Setup Guide | NetCloud24 Moodle LMS on Ubuntu 24.04 Server

Cloud Infrastructure Expert
Linux VPS & VPS Windows Setup Guide | NetCloud24 Moodle LMS on Ubuntu 24.04 Server





How to Install Moodle LMS on Ubuntu 24.04 Server Using Windows VPS


How to Install Moodle LMS on Ubuntu 24.04 Server Using Windows VPS

Moodle is a powerful open-source Learning Management System (LMS) used for creating and managing online courses. This guide provides step-by-step instructions for installing Moodle on an Ubuntu 24.04 server hosted on a Windows VPS using multiple methods: manual setup, Docker, Ansible, Kubernetes, and Terraform. Additionally, we’ll configure Let’s Encrypt for SSL and set up a domain. For reliable VPS hosting, consider Netcloud24 for robust Windows VPS solutions.

Power Your Moodle LMS with Netcloud24

Host your Moodle LMS on a high-performance Windows VPS from Netcloud24. Explore our services in your region:

Prerequisites

  • Ubuntu 24.04 VPS (e.g., from Netcloud24)
  • SSH access and root or sudo privileges
  • A registered domain name
  • Basic knowledge of Linux commands

Method 1: Manual Setup

Step 1: Update System and Install Dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install -y apache2 php php-mysql php-xml php-mbstring php-curl php-zip php-gd php-intl mysql-server unzip git
    

Step 2: Install Moodle

cd /var/www/html
sudo git clone -b MOODLE_404_STABLE git://git.moodle.org/moodle.git moodle
sudo chown -R www-data:www-data moodle
sudo chmod -R 755 moodle
    

Step 3: Configure MySQL

sudo mysql -u root -p
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'YourSecurePassword';
GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
    

Step 4: Configure Moodle

Copy the sample config file and edit it:

cd /var/www/html/moodle
sudo cp config-dist.php config.php
sudo nano config.php
    

Update the database settings in config.php:

$CFG->dbtype    = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'moodleuser';
$CFG->dbpass    = 'YourSecurePassword';
$CFG->wwwroot   = 'http://yourdomain.com';
$CFG->dataroot  = '/var/moodledata';
    

Create the data directory:

sudo mkdir /var/moodledata
sudo chown -R www-data:www-data /var/moodledata
sudo chmod -R 755 /var/moodledata
    

Step 5: Complete Installation

Access http://yourdomain.com in a browser and follow the Moodle setup wizard.

Method 2: Docker Setup

Step 1: Install Docker

sudo apt install -y docker.io
sudo systemctl enable docker
sudo systemctl start docker
    

Step 2: Run Moodle with Docker

sudo docker run -d --name moodle -p 80:80 -e MOODLE_DB_HOST=mysql -e MOODLE_DB_USER=moodleuser -e MOODLE_DB_PASSWORD=YourSecurePassword -e MOODLE_DB_NAME=moodle bitnami/moodle
sudo docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=YourSecurePassword -e MYSQL_DATABASE=moodle -e MYSQL_USER=moodleuser -e MYSQL_PASSWORD=YourSecurePassword mysql:8
    

Access Moodle at http://yourdomain.com.

Method 3: Ansible Setup

Step 1: Install Ansible

sudo apt install -y ansible
    

Step 2: Create Ansible Playbook

mkdir moodle-ansible && cd moodle-ansible
nano moodle.yml
    

Add the following to moodle.yml:

---
- hosts: all
  become: yes
  tasks:
    - name: Update apt cache
      apt:
        update_cache: yes
    - name: Install required packages
      apt:
        name: "{{ packages }}"
        state: present
      vars:
        packages:
          - apache2
          - php
          - php-mysql
          - mysql-server
          - git
    - name: Clone Moodle
      git:
        repo: 'git://git.moodle.org/moodle.git'
        dest: /var/www/html/moodle
        version: MOODLE_404_STABLE
    - name: Set permissions
      file:
        path: /var/www/html/moodle
        owner: www-data
        group: www-data
        mode: '0755'
        recurse: yes
    

Step 3: Run Playbook

ansible-playbook moodle.yml
    

Method 4: Kubernetes Setup

Step 1: Install Kubernetes

sudo apt install -y kubeadm kubectl kubelet
sudo kubeadm init
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
    

Step 2: Deploy Moodle

kubectl apply -f https://raw.githubusercontent.com/moodle/moodle-docker/master/k8s/moodle-deployment.yaml
kubectl apply -f https://raw.githubusercontent.com/moodle/moodle-docker/master/k8s/moodle-service.yaml
    

Access Moodle via the service endpoint provided by Kubernetes.

Method 5: Terraform Setup

Step 1: Install Terraform

sudo apt install -y terraform
    

Step 2: Create Terraform Configuration

mkdir moodle-terraform && cd moodle-terraform
nano main.tf
    

Add the following to main.tf (example for AWS, adjust for your provider):

provider "aws" {
  region = "us-east-1"
}
resource "aws_instance" "moodle" {
  ami           = "ami-0c55b159cbfafe1f0" # Ubuntu 24.04 AMI
  instance_type = "t2.medium"
  tags = {
    Name = "Moodle-Server"
  }
  user_data = <<-EOF
              #!/bin/bash
              apt update && apt upgrade -y
              apt install -y apache2 php php-mysql mysql-server
              git clone -b MOODLE_404_STABLE git://git.moodle.org/moodle.git /var/www/html/moodle
              EOF
}
    

Step 3: Apply Terraform

terraform init
terraform apply
    

Configuring Let’s Encrypt SSL

Step 1: Install Certbot

sudo apt install -y certbot python3-certbot-apache
    

Step 2: Obtain and Install SSL Certificate

sudo certbot --apache -d yourdomain.com
    

Follow the prompts to configure SSL. Certbot will automatically update Apache configuration.

Adding a Domain

Update your domain’s DNS records to point to your VPS’s public IP address. For Apache, configure a virtual host:

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

Add the following:


    ServerName yourdomain.com
    DocumentRoot /var/www/html/moodle
    
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    

    

Enable the site and reload Apache:

sudo a2ensite moodle.conf
sudo systemctl reload apache2
    

Conclusion

You’ve now learned how to install Moodle LMS on an Ubuntu 24.04 Windows VPS using manual setup, Docker, Ansible, Kubernetes, and Terraform, along with Let’s Encrypt SSL and domain configuration. For a seamless hosting experience, choose Netcloud24 for your VPS needs, offering reliable performance across multiple regions.

Why Choose Netcloud24?

Netcloud24 provides high-performance VPS solutions tailored for applications like Moodle. Visit our regional sites for more details:


Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24
In this section

More in Linux

Visit category

How to Set up PostgreSQL Replication on Debian 11

  Introduction PostgreSQL is a powerful, open-source object-relational database system that offers advanced features for database management. Setting up replication is essential for ensuring high availability and load…

Comments are closed.