Skip to content
Follow
CMS Windows

Ultimate Guide: Install Moodle on Windows WSL

Richard
Written by
Richard
Jun 16, 2021 Updated Sep 15, 2026 9 min read
How to Enable or Disable Cellular Use in Windows 11
How to Enable or Disable Cellular Use in Windows 11

Moodle is a free learning management system that lets you build online classes, create quizzes, and share study materials on your PC without paying for web hosting. Running this setup on Windows 10 or Windows 11 gives you a local testing space that works like a real internet server.

Advertisement
⚡ Quick Answer

Enable WSL and Virtual Machine Platform via PowerShell, then install Ubuntu from the Microsoft Store. Set WSL 2 as default and install the Apache web server and MariaDB database within Ubuntu.

Advertisement

The Windows Subsystem for Linux (WSL), a compatibility layer that lets you run Linux natively in Windows, speeds up file access so Moodle runs smoothly.

  1. Turn on the Windows Subsystem for Linux (WSL) and the Virtual Machine Platform. You’ll need to restart your computer after this.
  2. Set WSL 2 as the default version by opening PowerShell as an administrator and running the command wsl --set-default-version 2.
  3. Install Ubuntu from the Microsoft Store. Launch it and create a new UNIX username and password.
  4. Install the Apache web server by running sudo apt update and then sudo apt install apache2 in your Ubuntu terminal.
  5. Install MariaDB (a database server) by running sudo apt install mariadb-server mariadb-client and then securing it with sudo mysql_secure_installation.
  6. Install PHP and its required modules using the command sudo apt install php libapache2-mod-php php-imagick php-imap php-json php-ldap php-common php-pgsql php-ssh2 php-sqlite3 php-xml php-soap php-mysql php-gmp php-curl php-intl php7.4-mbstring php-xmlrpc php-gd php-xml php-cli php-zip.
  7. Create a database and user for Moodle within MariaDB.
  8. Download the latest Moodle files using Git and set the correct permissions.
  9. Configure Apache to recognize Moodle and then restart the Apache service.
  10. Open your web browser and go to http://localhost to run the Moodle installation wizard and complete the setup.

Enable WSL in Windows

Windows Subsystem for Linux (WSL) lets your Windows computer run Linux programs directly, setting up the foundation for your Moodle environment. To enable this feature and install Moodle WSL Windows, open PowerShell as an administrator by clicking Start, typing PowerShell, right-clicking Windows PowerShell, and selecting Run as administrator.

What to do: Open PowerShell as an administrator. Click Start , then type PowerShell. Right-click Windows PowerShell and select “Run as administrator.”

PowerShell terminal running as administrator for WSL
powershell administrator

Now run this command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Advertisement

You should see a success message like this:

Deployment Image Servicing and Management tool
Version: 10.0.19041.844

Image Version: 10.0.19042.844

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Advertisement

Enable Virtual Machine Platform

Virtual Machine Platform is an essential feature that allows WSL 2 to manage the virtual environment needed for Linux applications, ensuring Moodle functions correctly. To enable this, run the DISM command from your open PowerShell window to configure the system components properly.

Run this command from the same PowerShell window:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

If you're using Windows 10 version 2004 or older, use this command instead:

Advertisement

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

⚠️WarningAfter running these commands, restart your computer.

This lets all the changes take effect. If you don't restart, the next command won't work.

After restarting your computer, open PowerShell as administrator again. Run the command `wsl --set-default-version 2` to set the Windows Subsystem for Linux (WSL) 2 as the default version. This step ensures that Moodle installations utilize the newer, more capable WSL 2 architecture, which offers better performance and compatibility for Linux environments.

wsl --set-default-version 2

Advertisement

Install Ubuntu on 🪟 Windows 10

Ubuntu on Windows 10 creates the Linux environment required to install Moodle WSL Windows. Ubuntu provides the necessary Linux terminal and command-line tools for running Moodle and its associated software, and you can download it directly from the Microsoft Store.

Open this link to download Ubuntu 20.04 from the Windows Store:

Ubuntu provides a Linux terminal with command-line tools such as bash, ssh, git, apt, and more.

Advertisement
Ubuntu installation screen on Windows WSL
ubuntu windows wls install

Click the Get button and install it. After installing, launch Ubuntu from WSL.

Ubuntu will ask you to create an account. Follow the prompts:

Installing, this may take a few minutes.
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: user
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64)

Advertisement

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

System information as of Mon Apr 12 17:57:37 CDT 2021

System load: 0.52 Processes: 7
Usage of /home: unknown Users logged in: 0
Memory usage: 26% IPv4 address for eth0: 192.168.1.100
Swap usage: 0%

1 update can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable

Great! Ubuntu is now installed.

If you run into problems, try these commands:

wsl --set-default-version 1
bcdedit /set hypervisorlaunchtype auto start

Install Apache HTTP Server

Apache HTTP Server acts as a web server on your Ubuntu WSL, handling requests from browsers so they can display your Moodle site and its content. You install and manage this web server using standard apt package manager commands in your Linux terminal.

Run these commands:

sudo apt update
sudo apt install apache2

You can use these commands to control Apache:

sudo service apache2 stop
sudo service apache2 start
sudo service apache2 restart

To check if Apache is working, open your browser and go to:

http://localhost

You should see an Apache test page.

LAMP stack setup on Windows WSL with Ubuntu
lamp windows wsl ubuntu

Install MariaDB Database Server

MariaDB Server stores all important Moodle data, such as course details and user accounts, within your WSL setup. MariaDB is open-source, fast, and secure, making it the standard database choice for most Linux systems hosting Moodle.

MariaDB is open-source, fast, and secure. Most Linux systems use it.

Run this command:

sudo apt install mariadb-server mariadb-client

You can use these commands to control MariaDB:

sudo service mysql stop
sudo service mysql start
sudo service mysql restart

⚠️WarningNow secure your database by setting a root password.

Run this command:

sudo mysql_secure_installation

Answer the questions like this:

Enter current password for root (enter for none): Press the Enter key

Set root password? [Y/n]: Y

New password: Enter a password

Re-enter new password: Repeat the password

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

To verify MariaDB is working, log in with this command:

sudo mysql -u root -p

Type your root password when asked. You should see:

Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 46
Server version: 10.3.29-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]>

Great! MariaDB is installed.

PHP and all its required modules are essential for Moodle to function correctly and process its web pages on your WSL system. You install these software packages using the terminal to give Moodle the backend scripting language it needs.

Run this command to install PHP and all required modules:

sudo apt install php libapache2-mod-php php-imagick php-imap php-json php-ldap php-common php-pgsql php-ssh2 php-sqlite3 php-xml php-soap php-mysql php-gmp php-curl php-intl php7.4-mbstring php-xmlrpc php-gd php-xml php-cli php-zip

To check if PHP is installed correctly, run:

php -v

You should see something like:

PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

You can also test PHP by creating a test file. Run this command:

sudo nano /var/www/html/phpinfo.php

Type this content:

<?php phpinfo( ); ?>

Save the file. Restart Apache, then open your browser and go to:

http://example.com/phpinfo.php

You should see a PHP information page.

PHP test page running on Windows WSL
lamp windows wsl php test

Create Moodle Database

A dedicated database securely stores all your course and user information within MariaDB on WSL. You create this specific database and a corresponding user account using the MySQL command-line interface to hold your Moodle content and settings.

Log into MariaDB with this command:

sudo mysql -u root -p

Create a database called moodle:

CREATE DATABASE moodle;

Create a database user called moodleuser:

CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY 'new_password_here';

Give the user full access to the moodle database:

GRANT ALL ON moodle.* TO 'moodleuser'@'localhost' WITH GRANT OPTION;

Save your changes and exit:

FLUSH PRIVILEGES;
EXIT;

Download Moodle

Moodle files are downloaded using Git to get the platform running on your Windows WSL setup. This method fetches the files directly from Moodle's official source to ensure you have the most current version for your installation.

First, install git and curl:

sudo apt install git curl

Go to the Apache directory and download the latest Moodle version:

cd /var/www/
sudo git clone -b MOODLE_39_STABLE git://git.moodle.org/moodle.git moodle

To see the latest Moodle versions, check this link:

Now set the correct permissions so Moodle can work:

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

Configure Apache

Apache configuration files direct the web server to find Moodle's files and serve your website correctly. You create this special configuration file on your WSL server to tell Apache how to handle incoming browser requests.

Create a new Apache configuration file:

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

Copy and paste this configuration:

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/moodle

<Directory /var/www/moodle/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save the file. Then enable the new site and restart Apache:

sudo a2ensite moodle.conf
sudo a2enmod rewrite
sudo service apache2 restart

Launch Moodle

Moodle launches on your Windows WSL installation when you visit the configured web address in your browser after setup is complete. This action starts the Moodle setup wizard, guiding you through the final language selection and directory confirmation steps.

Open your browser and go to:

http://example.com

The Moodle installation wizard should open.

First, choose your language:

Moodle installation process on Windows WSL
moodle windows wsl install

Next, confirm the Moodle directories:

  • Moodle directory: The folder with Moodle's code
  • Data directory: Where Moodle stores files users upload
Moodle directory structure on Windows WSL
moodle windows wsl directory

Choose your database type. MariaDB is what we installed:

Database connection setup for Moodle on WSL
moodle windows wsl database connection

Enter your database details:

  • Database name: moodle
  • Username: moodleuser
  • Password: The password you created
Moodle database name and password configuration on WSL
moodle windows wsl database name and password

Continue through the installer. Check that everything meets the requirements.

Create your main admin account. This person will control the entire site. Use a strong password and a real email address:

Creating admin account for Moodle on Windows WSL
moodle windows wsl admin account

Once done, Moodle is ready to use:

Moodle dashboard interface on Windows WSL
moodle windows wsl dashboard

Summary

Install Moodle WSL Windows process is now successfully completed after enabling WSL, installing Ubuntu, Apache, MariaDB, PHP, and setting up Moodle. This configuration gets the learning platform ready for use on your local machine.

  1. Enabled WSL 2 on Windows
  2. Installed Ubuntu Linux on your Windows machine
  3. Installed Apache web server
  4. Installed MariaDB database
  5. Installed PHP and required modules
  6. Created a Moodle database and user
  7. Downloaded Moodle from GitHub
  8. Configured Apache for Moodle
  9. Ran the Moodle installation wizard

Moodle is now running on your Windows computer. You can use it to create courses, manage students, and deliver online education.

How to install and use WSL on Windows?

Right inside of Windows. No dual boot no separate VM instead running a full Linux environment on your Windows machine. Set it up by opening PowerShell and typing wsl --install.

How to install Moodle in Linux?

Tgz files serve as Moodle installation archives necessary for setting up the platform. After extracting these files, verify that PHP is installed on the server.

Was this guide helpful?

📬 Get new Windows tips in your inbox
One email when we publish something worth your time. No spam, unsubscribe anytime.
Tags: #Moodle #Windows 10
Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

3242 articles → Twitter
Advertisement

📚 Related Tutorials

How to Install PrestaShop on Windows WSL
CMS How to Install PrestaShop on Windows WSL
How to Enable or Disable Virtual Machine Platform in Windows 11
Windows How to Enable or Disable Virtual Machine Platform in Windows 11
How to Install Ubuntu Linux
Ubuntu Linux How to Install Ubuntu Linux
How to Access Linux Files on Windows 11 Using WSL
Windows How to Access Linux Files on Windows 11 Using WSL

1 Comment

Leave a Comment

Your email address will not be published. Required fields are marked *