Categories: LinuxLMSopen source

How to install moodle in ubuntu 20.04-LTS with the help of docker compose

Are you looking for an efficient way to install Moodle on your Ubuntu 20.04 LTS Server? If so, you’ve come to the right place! This guide will walk you through the entire installation process step-by-step, using Docker-Compose to simplify the process. Additionally, we will cover the minimum server requirements for Moodle production use, the UFW settings in SSH Client, and how to install Docker-Compose with a simple script. And if you’re interested in more tech content like this, be sure to subscribe to OldieTech’s YouTube channel!

Section 1: Minimum Server Requirements for Moodle Production Use

Before diving into the installation process, it’s essential to ensure that your server meets the minimum requirements for Moodle production use. These requirements include:

  • At least 2GB of RAM
  • Dual-core CPU
  • 20GB of disk space
  • Ubuntu 20.04 LTS Server installed

Section 2: Setting Up UFW in SSH Client

Once you’ve confirmed that your server meets the minimum requirements, the next step is to set up UFW in SSH Client. This is important for ensuring that your server is secure and protected from potential threats. Here’s how to do it:

## Log in to your server via SSH
## Install UFW by running the command 
sudo apt-get install ufw

## Allow SSH connections by running the command 
sudo ufw allow ssh

## Allow HTTP and HTTPS connections by running the command 
sudo ufw allow http
sudo ufw allow https
sudo ufw allow 81/tcp
sudo ufw allow 7443/tcp
sudo ufw allow 8080/tcp

## Enable UFW by running the command 
sudo ufw enable

## Check Status
sudo ufw status

Section 3: Install Docker and Docker-Compose with Simple Script:

Docker-Compose is a tool that allows you to define and run multi-container Docker applications. Here’s how to install Docker-Compose on your Ubuntu 20.04 LTS server with a simple script:

## Create a directory 
nano in.sh

## Paste below code 
#################

apt update && 
apt upgrade -y &&
curl -fsSL https://get.docker.com -o get-docker.sh &&
sudo sh get-docker.sh &&
curl -SL https://github.com/docker/compose/releases/download/v2.13.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose &&
chmod +x /usr/local/bin/docker-compose &&
apt-get install docker-compose-plugin

#################

## activate the execution mode of "in.sh"
chmod +x in.sh

## after that, you can run this script
./in.sh

Section 4: Installing Moodle on Ubuntu 20.04 LTS Server with Docker-Compose

Section 4: Installing Moodle on Ubuntu 20.04 LTS Server with Docker-Compose

With Docker-Compose installed, you’re now ready to install Moodle on your Ubuntu 20.04 LTS Server using Docker-Compose. Here’s how to do it:

  • Log in to your server via SSH
  • Create a directory to store your Moodle installation files
sudo mkdir -p /var/www/html/moodle
cd /var/www/html/moodle

## Create a Docker Compose file called docker-compose.yml in this directory
nano docker-compose.yml

## copy the below code and paste into docker-compose.yml file
#################

version: '2'
services:
  mariadb:
    image: mariadb
    volumes:
      - /srv/Configs/Databases/Moodle:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=moodle
      - MYSQL_ROOT_USER=root
      - MYSQL_DATABASE=moodle
      
  moodle:
    image: bitnami/moodle:latest
    ports:
      - 8080:8080
      - 8443:8443
    environment:
      - MOODLE_DATABASE_HOST=mariadb
      - MOODLE_DATABASE_USER=root
      - MOODLE_DATABASE_PASSWORD=moodle
      - MOODLE_DATABASE_NAME=moodle
      - PUID=998
      - PGID=100
    volumes:
      - /srv/Configs/Moodle:/bitnami/moodle
      - /srv/Configs/MoodleData:/bitnami/moodledata
    depends_on:
      - mariadb
    links:
      - mariadb:mariadb

Note: Replace ‘your_password_here‘ and ‘your_root_password_here‘ with your own passwords.

## run docker-compose file
sudo docker-compose.up -d

Once the installation is complete, you can access your Moodle site by going to http://your_server_ip_address:8080 with port in your web browser.

Note: If you face any problem in installation, you can also watch my video tutorial on YouTube

Section 5: SSL Certificate

For SSL Certificate we need to install Nginx Proxy Manager (NPM). How to install Nginx Proxy Manager on a same server with the help of docker compose please follow the instructions below

## make a directory for Nginx Proxy Manager
cd
mkdir npm
cd npm

## create a file "docker-compose.yml" init
nano docker-compose.yml

## paste the below code init

version: '3.8'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
## run this below command
docker-compose up -d

Once the installation is complete, you can access your “Nginx Porxy Manager” site by going to http://your_server_ip_address with “port 81” in your web browser. By default login detail is

Email = admin@example.com

Password = changeme

Now goto Hosts >> Proxy Host and click button “Add proxy Host” new pop window will be appear. where you fulfill the detail according your scenario.

Domain Names = example.com
Schema = https / http
Forward Hostname / IP  = your server IP
Forward Port = your moodle port

## Check option "Block Common Exploits"
## Check option "Websockets Support"
## click Save Button

New record will be create with your domain name. you can click on domain and you will noticed that your domain mapped with your server IP successfully.

Generate SSL Certificate: Goto Hosts >> Proxy Host >> SSL

  • Choose “Request a new SSL Certificate”
  • Enable the “Force SSL” option
  • Give Valid Email
  • Save the changes.

Nginx Proxy Manager will automatically generate an SSL certificate using Let’s Encrypt for the specified domain. Now, when accessing your application using the domain name, Nginx Proxy Manager will handle SSL termination and proxy the requests to your Docker container.

Feeling lost in the tech jungle? Say hello to Oldie Tech, your friendly guide!

No more confusing jargon or frustrating updates! In my videos (Urdu/Hindi with English subtitles!), I take complex tech and break it down into bite-sized, easy-to-understand pieces. Think of me as your tech translator, turning mysteries into simple solutions with a sprinkle of humor and helpful tips. ✨

Whether you’re a tech newbie or just prefer your tech talk with a bit of flavor, Oldie Tech welcomes you with open arms. Join our supportive community and ditch the tech fear! Subscribe now:

kash

View Comments

  • Hi,
    please, could you check the:
    "Section 4: Installing Moodle on Ubuntu 20.04 LTS Server with Docker-Compose" in the link you have attached.
    What you did in the video seems different, so I don't know which is the correct one.
    thanks

  • Hi, thanks for your guide.
    I have a question. Lets Say I already have a running docker container with Mariadb where I want to keep all databases for different services I have running.
    How can I modify your provided docker compose to make moodle connect to that Mariadb server instead.
    Could you please provide a docker compose file that will fit for that scenario?
    Thanks

Recent Posts

How to Install Rallly with Docker Compose

What is Rallly? Rallly is an open-source scheduling and collaboration tool designed to make it…

2 weeks ago

How to Install OpenProject: A Step-by-Step Guide for Beginners

Introduction OpenProject is a project management tool designed to help teams organize, collaborate, and track…

2 months ago

Part 2: Jitsi Meet Host Authentication & JWT Token Configuration

Hey there! Welcome back to the website, and today we're diving deeper into Jitsi Meet.…

7 months ago

Self-Hosted Chat: Set Up Your Own Mattermost Server with Ease

Introduction Boost your team's collaboration and productivity with Mattermost, a secure and versatile communication platform.…

9 months ago

How to install n8n in Linux using Docker-Compose

Introduction n8n.io is your secret weapon for workflow automation! It's a user-friendly platform that lets…

10 months ago

How to Install Nextcloud All-in-One on Linux

What is Nextcloud? Nextcloud is an awesome open-source platform that gives you exactly that. Think…

11 months ago